Hi Guys,
Thanks for the help. I have another problem. The UPDATE statement isn't running correctly. I have a hunch the FormId is not being passed properly to the UPDATE statement. If you could have a look please. Sorry for the long code:
<?php
include ("db/connect.php");
include ('includes/error.php');
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$FormId = isset($_GET['user_id']) ? $_GET['user_id'] : "";
$queryselect = "SELECT FormId, FirstName, LastName, Email, Age, Birthdate, FavLanguage FROM Form WHERE FormId = '$FormId'";
$result = mysqli_query($link, $queryselect);
if (!$result) {
printf("Error in connection: %s\n", mysqli_error($link));
exit();
}
$table = [];
while ( $row = mysqli_fetch_assoc( $result ) ) {
$table[] = $row;
}
if ( count($table) != 1) {
exit;
}
else
{
print_r($table);
$first_name = $table[0]["FirstName"];
$last_name = $table[0]["LastName"];
$email = $table[0]["Email"];
$age = $table[0]["Age"];
$birthday = $table[0]["Birthdate"];
$favlanguage = $table[0]["FavLanguage"];
}
$fname="";
$lname="";
$email1="";
$age1="";
$birthday1="";
$fav_language1="";
if(isset($_POST['fname'])){
$fname=$_POST['fname'];
}
if(isset($_POST['lname'])){
$lname=$_POST['lname'];
}
if(isset($_POST['email'])){
$email1=$_POST['email'];
}
if(isset($_POST['age'])){
$age1=$_POST['age'];
}
if(isset($_POST['birthday'])){
$birthday1=$_POST['birthday'];
}
if(isset($_POST['fav_language'])){
$fav_language1=$_POST['fav_language'];
}
$updatequery = "UPDATE Form SET FirstName = '$fname', LastName = '$lname',
email = '$email1', age = '$age1', Birthdate= '$birthday1', FavLanguage = '$fav_language1' WHERE FormId = '$FormId'";
$result1 = mysqli_query( $link, $updatequery );
echo ("id is: $FormId");
?>