Reputation: 25
So, i was working on my website. And after 10 minutes I was ready. I tried it. I have 4 column in my database. id
, times
, left_over
and bruh
. When I tried it Everything was getting inserted but not bruh
, I don't know what I've did wrong. Here is my script:
$link = mysqli_connect("localhost", "root", "", "testang");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$channelid = mysqli_real_escape_string($link, $_POST['channelid']);
$subs = mysqli_real_escape_string($link, $_POST['subs']);
$points = $subs*20;
$lell = $userRow['userid'];
$lel = $userRow['userpoints'];
$pointsreal = $lel - $points;
if ($points > $lel) {
header("Refresh:0; url=NO.php");
}
$bew = "INSERT INTO yt (times, left_over, bruh)
VALUES ('0', '$subs', '$channelid')";
if ($link->query($bew) === TRUE) {
echo "";
} else {
echo "Error: " . $bew . "<br>" . $link->error;
}
mysqli_close($link);
And I don't get any messages that there's gone something wrong. Everything is getting inserted but bruh
not. Does some one know why?
This is my form:
<form action="insert.php" method="post">
<p>
<label for="firstName">Youtube channel ID</label><br>
<input type="text" name="id" id="channelid">
</p><br><br>
<p>
<label for="lastName">What is your email?</label><br>
<input type="text" name="subs" id="subs">
</p><br><br>
<input type="submit" value="Submit">
</form>
Upvotes: 2
Views: 66
Reputation: 7093
Now that I know from comments what's wrong, let me clarify a bit what's wrong in here. In your field:
<input type="text" name="id" id="channelid">
You have ID: channelid
and name: id
. To be able to get $_POST['channelid']
, you need to set attribute name
with the same string as in your $_POST
index. Therefore:
<input type="text" name="channelid" id="channelid">
Upvotes: 1