I am trying to update the table but nothing is changing. The database name and fields are correct.
<?php
require("config.php");
$forname = $_POST['name'];
$newval = "yes";
mysqli_query($con, "UPDATE pupils SET signin = '$newval' WHERE forname = '$forname'");
mysqli_close($con);
?>
Help appreciated! Thanks,
UPDATE
Appears that data is not posting correctly for some reason.
<form class="form-inline" name="markin" role="form" method="POST" action="markin.php">
<div class="form-group">
<select class="form-control" name"name" id="name">
<?php
$query = "SELECT * FROM `pupils` WHERE signin = 'no'";//Grab the data
$result = mysqli_query($con, $query);
while ($row = mysqli_fetch_array($result)) {//Creates a loop to loop through results
echo "<option>" . $row['forname'] . "</option>";//$row['index'] the index here is a field name
}
?>
</select>
</div>
<button type="submit" class="btn btn-success">Mark in</button>
</form>
This is a terrible way to use the mysqli extension.
First, I suggest you read the prepared statements quickstart guide which would lead you to something like this...
As an added bonus, you should set mysqli to throw exceptions on error so you don't have to check return values all the time. In your
config.php
file, before creating the connection, do this...and as mentioned in the comments, the
php.ini
file in your development environment should enable full error reporting with the following directivesTo directly answer your question, you're missing an equals sign for the
<select>
elementsname
attribute. It should be