Redirect to Profile after Updating Profile

By Rusty - December 16, 2010 - edited: December 16, 2010

I'm trying to figure out how to redirect the user to another page after the POST of their updated Profile data. Similar to how after POSTing the Login page it goes to a redirect (which you can define in websitemembership.php).

Any thoughts? I'm currently poking around in there to figure out what I can come up with.

I see where we declare the links that we want to redirect to:
// UPDATE THESE VALUES

$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'] = '/login.php'; // url to login form
$GLOBALS['WEBSITE_LOGIN_SIGNUP_URL'] = '/signup.php'; // signup url linked to from the login page
$GLOBALS['WEBSITE_LOGIN_REMINDER_URL'] = '/reminder.php'; // password reminder url linked to from the login page
$GLOBALS['WEBSITE_LOGIN_PROFILE_URL'] = '/profile.php'; // url to "edit my profile" page

$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'] = '/index.php'; // user gets redirected here after login
$GLOBALS['WEBSITE_LOGIN_POST_LOGOFF_URL'] = '/index.php'; // user gets redirected here after logoff


I can see where the Login Form has this bit of code:

<input type="hidden" name="action" value="login" />

I also see where the update Profile form has this
<input type="hidden" name="save" value="1" />

and I also see where the WebsiteMembership.php has its Post-Login Success redirect:
// redirect on success
if (@$_SESSION['lastUrl']) { $postLoginUrl = @$_SESSION['lastUrl']; }
else if ($GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']) { $postLoginUrl = $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']; }
else { $postLoginUrl = thisPageUrl(); }
$redirectUrl = $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'];

unset($_SESSION['lastUrl']);
redirectBrowserToURL("$postLoginUrl");
exit;

}

Rusty

Re: [Rusty] Redirect to Profile after Updating Profile

By Jason - December 16, 2010

Hi Rusty,

You can do this right in the code. Right after you finish updating the information in the database, you can use this function:

redirectBrowserToURL("YOUR_PAGE.php");

this will redirect you to any page you specify.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/