I am very new to php and need some help please!
I am using a text box to display a value from a table which I would like then be able to be edited and used for an update statement.
This text box currently gets populated based on what the $studentId is and this works fine.
$conn = connection();
$sql = "SELECT * FROM students WHERE studentId=$studentId";
foreach ($conn->query($sql) as $row) {
?>
<form>
Student Name: <input name="name" type="text" method="post" value="<?php echo( htmlspecialchars( $row['name'] ) ); ?>" />
<br>
<input name="submitStudentUpdate" type="submit" value="Update" />
</form>
<?php
}
connection(); is being provided from another page.
It's this line I need the value of
Student Name: <input name="name" type="text" method="post" value="<?php echo( htmlspecialchars( $row['name'] ) ); ?>" />
I would like to retrieve the value from this form and post to another page to be used in an update statement but how do I get at it?
I thought it may be:
if (isset($_POST['name'])) {
echo $_POST['name'];
}
So currently, text box gets populated with
[Bob]
And I would like to be able to change it to, e.g.
[Bobby]
hit the submit button and retrieve this value.
I am using PDO.
Hope this makes sense and any help much appreciated. Thankyou.