I'm having a bit of trouble with my update query in mysql database. I have a login form which, when the user logs in, creates the email, password and ID of the user and stores it in a session(not sure if this is the safest way, please advise me the correct/safest way). When they are logged in, they can go and change their password(or supposed to be). The problem is that the update password query is not working for me.
Here is my code that sets the ID, email and password of the user when they log in:
session_start();
$_SESSION['id'] = $id;
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
Here is the code that is meant to update their password:
session_start();
if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['newPassword']) && isset($_POST['oldPassword'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$newPassword = $_POST['newPassword'];
$oldPassword = $_POST['oldPassword'];
mysql_select_db("users", $conn);
if(isset($_POST['update'])) {
$update = "UPDATE users SET Password='$newPassword' WHERE Password='$_POST[hidden]'";
mysql_query($update, $conn);
$_SESSION['password'] = $newPassword;
}
I have an 'Old password' box that checks if their old password is correct and a 'New password' box that is meant to be the new password of the user when they click 'update'.
The problem is that when I click update nothing happens. I tried using the mysql_error() function, but it didn't work. The page refreshes too fast. Please note that this is not all of the code, if you want to download it: https://www.mediafire.com/?fkjwt58hk5kyt3w Hi guys, I'm having a bit of trouble with my update query in mysql database. I have a login form which, when the user logs in, creates the email, password and ID of the user and stores it in a session(not sure if this is the safest way, please advise me the correct/safest way). When they are logged in, they can go and change their password(or supposed to be). The problem is that the update password query is not working for me.
I know this mysql way of doing things is very insecure, vulnerable to sql injection and old way of doing it, but this is just practice and is for fun. Afterwards, I will learn how to prevent sql injection and XSS.
I have ready mean other possts on this site with similar problems, but they have not helped me at all, I've searched Google alot and searched it on YouTube. Nowhere works for me!!!
Please help! Thanx in advance
If there is anything else you would like me to post or I haven't said something, just let me know.
PS: If you can, please download all the files and check them and run them yourself :)