Reputation: 47
I have this problem, it should be easy to solve. But i'm new to PHP so please help.
The problem is :
Profile page doesn't update after update in mySQL database
For example :
1. User edit their profile (e.g. First Name)
2. Click on update.
3. PHP script to update mySQL runs perfectly.
4. First Name in mySQL updated to the new input.
5. The page redirects to profile page.
6. Problem= The first name is the previous first name.
Users need to log out and sign in again to see their new updated first name.
Here is the code to view the first name in the profile page:
echo '<h1>' . $_SESSION['fname'] . '';
Please help. Thank you.
Upvotes: 0
Views: 252
Reputation: 790
The problem is that,you are not reseting $_SESSION['fname']. You should unset that session using unset($_SESSION['fname']); and then set it up again.
Upvotes: 1
Reputation: 34426
You're not changing the $_SESSION['fname']
when you do the update. It is only set when you do the login. Because of that you will continue to echo out the data from the $_SESSION
array until a change is made. Add something to the PHP script that does the database update to update the $_SESSION
array.
Upvotes: 0