I am experiencing a problem when I attempt to edit a record in a Student Record database in PHPMyAdmin. When the user wants to update a record they click an update button which brings them to a screen with the current field values with an input type text option to change the field value. However when the user clicks on submit the code only updates the amended field value and deletes the other values. The following is the code I am using.
Code:
<?php
if(isset($_POST['subEdit'])) {
$subEdit = $_POST['subEdit'];
} if(!empty($subEdit)){
$surname= $_POST['surname'];
} else{
$surname= $surname;
}
if(isset($_POST['subEdit'])) {
$subEdit = $_POST['subEdit'];
} if(!empty($subEdit)){
$firstName= $_POST['firstName'];
} else{
$firstName= $firstName;
}
{
$sql ="UPDATE personal_details SET surname='$surname', firstName='$firstName' WHERE userName='$userName'";
if (!mysql_query($sql))
{
die('Could not connect: ' . mysql_error());
}
}
?>
Does anybody have any suggestions as to how I can alleviate this issue?
Thanks
Bookmarks