Forums

Profile Update

omidhz 15 Oct, 2018
Hi,
I designed a custom form for the profile update. Everything is working great when the user updates their profile information (name, email or password). However, I have two problems:
  1. When user enters a new name in the form and submits the form, the name is updated in the database. However, if user returns to the profile update form, the field name still showing the old name. This stays the same even if I go to other pages and then come back. The only way it changes to the new name is for the user to log out then log back in. I already changed the form option on "Keep alive" to NO. but the problem still exists.
  2. With this custom form, users can enter emails that are already assigned to another user. How can I prevent this from happening? It needs to check the existing emails and give error message if email already exists. But I'm not sure how to do that.
Thanks
healyhatman 15 Oct, 2018
Try using a redirect after the successful submission, to make sure it's actually clearing the data. Otherwise the data is still in session and it will load it back into the field.

For the emails - just do a read_data on the users table (set to first matching) Then an event switcher - if it's empty, fine! If it's not empty, another switch to check if the email is for the user (fine!) or if it's for someone else (not fine!)
omidhz 16 Oct, 2018
Thank you for your reply.
I was able to figure out the email search situation and it is now working fine.
But the first problem still exists. I added a redirect after my form is submitted, but when I go back to the form, it still showing the old data, while the database is updated with new data.
healyhatman 16 Oct, 2018
So you're using a redirect action right, not an event loader?
omidhz 16 Oct, 2018
Yes, I'm using redirect at the end. Here is a screenshot for better visualization:
healyhatman 16 Oct, 2018
So do you mean when you click the "back" button, or when you reload the form as new?
omidhz 16 Oct, 2018
Either way, it shows the old information. Even if I browse the site for few minutes and then I load the form using a link it still shows the old data.
Maybe I need to add a command to kill the session when the form loads? Do you think that will fix the problem? how can I do that without logging out the user?
healyhatman 16 Oct, 2018
You can use a multi-page action, with the mix data with global and clear data boxes ticked maybe?
omidhz 16 Oct, 2018
I added a Multi Page to the begining of Submit section and checked both boxes. Still the same result.
healyhatman 16 Oct, 2018
Should be at the end but yeah. So weird. Maybe your server is caching queries?
omidhz 16 Oct, 2018
I also tried to put the Multi page at the end, but still the same.
omidhz 16 Oct, 2018
Answer
Ok, finally I think I found a solution for this.
I added a custom php code at the end of my form and cleared all sessions using:
$_SESSION = array();
This took care of the problem.
From what appears it is doing what it should, withouth logging the user out.
Do you see any issues with this method?
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger