I'm sorry to ask such a narrow question, but I have this code in PHP and it is supposed to update a user's account. There is no error being returned and my IDE cannot identify the problem either. The problem is now that the code is not updating the database. I hope I can get some help on the subject.
Here is my PHP code:
<?php
session_start();
$con = mysqli_connect("mysql.serversfree.com", "u190182631_embo", "17011998embo", "u190182631_login");
$username = $_POST['user_name'];
$last = $_POST['lname'];
$first = $_POST['fname'];
$address = $_POST['address'];
$email = $_POST['email'];
$year = $_POST['year'];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE users SET last_name = '$last'
WHERE user_name = $_SESSION[user_name]");
mysqli_close($con);
}
?>
Any my HTML form if that is needed:
<form method="post" action="update.php">
Username: <input type="text" name="user_name" value="<?php echo $_SESSION['user_name']?>"><br><br>
Email: <input type="text" name="email" value="<?php echo $_SESSION['user_email']?>"><br><br>
Last Name: <input type="text" name="lname" value="<?php echo $_SESSION['last_name']?>"><br><br>
First Name: <input type="text" name="fname" value="<?php echo $_SESSION['first_name']?>"><br><br>
Street Address: <input type="text" name="address" value="<?php echo $_SESSION['address']?>"><br><br>
Year Graduated: <input type="text" name="year" value="<?php echo $_SESSION['year']?>"><br><br>
<input type="submit" value="Update Information"><br>
</form>
<form method="link" action="manage.php">
<input type = "submit" value = "Cancel"><br>
</form>
Any help would be great!