I have recently started to write in PHP for my university course and am a little confused over an issue. I'm having problems using header("Location: mylink"); to redirect the users between pages.
Here is the relevant code:
Code: Select all
//Let the user update the information in the textboxes.
if(isset($_POST["update"]))
{
$updateQuery = //query here
$queryExec = mysql_query($updateQuery);
header("Location : profile.php");
}
I am trying to automatically redirect the user from the EditProfile page, back to their original Profile page without an intermediate "You have updated your profile" dialog in between.
Sorry if this is a silly question, but I cannot see why header() doesn't execute in a POST environment.
Any help would be muchly appreciated and gratefully recieved.
Thanks,
DSpeed
EDIT:
Just to add, in a different page, I have been able to achieve this so am confused concerning why it will not execute now:
Code: Select all
if(isset($_POST["submit"]))
{
$loginUserQuery = "SELECT * FROM users WHERE UserNick = '$_POST[username]' AND UserPass = '$_POST[password]'";
$queryExec = mysql_query($loginUserQuery);
$queryResult = mysql_fetch_object($queryExec);
if(!empty($queryResult))
{
//dump the query in to a new object, and register it as a global with the sessiojn
$UserObj = $queryResult;
$_SESSION['UserObj'] = $UserObj;
header('location: profile.php'); ///// <--- This works
}
else
{
echo("User not found");
}
}