Hello Folks,
I cannot see anymore. header() will not redirect.
Can some one take a look at this and tell me why is it that header() is not redirecting please?
If variable $good is false then the section of code where the creation of the object "admin" is avoided and header redirects successfully at the end of the script. However, if everything is good and this section is executed then header at the end will not redirect. The rest of the script seems to be working fine because when $good is True and the updates takes place all the session vars are set including $update_msg. If I hit the back button everything is there but header wont take me there.
Any hint would be appreciated.
<?php
session_start();
require_once('verify_user.php');
require_once('classes/admin.cls');
require_once('includes/utilities.inc');
$good = true;
$update_msg = "";
$oldPwd = (isset($HTTP_POST_VARS['oldPwd'])?$HTTP_POST_VARS['oldPwd']:"");
$newPwd1 = (isset($HTTP_POST_VARS['newPwd1'])?$HTTP_POST_VARS['newPwd1']:"");
$newPwd2 = (isset($HTTP_POST_VARS['newPwd2'])?$HTTP_POST_VARS['newPwd2']:"");
$adEmail = (isset($HTTP_POST_VARS['adEmail'])?$HTTP_POST_VARS['adEmail']:"");
$adPhone = (isset($HTTP_POST_VARS['adPhone'])?$HTTP_POST_VARS['adPhone']:"");
if ( empty($oldPwd) )
{
$update_msg = '<b class="required">Your current password is required</b><br>';
$good = false;
}
if ( !empty($newPwd1) && empty($newPwd2))
{
$update_msg.= '<b class="required">You need to re-type to confirm the new password</b><br>';
$good = false;
}
elseif ( empty($newPwd1) && !empty($newPwd2))
{
$update_msg.= '<b class="required">Your new password is required</b><br>';
$good = false;
}
elseif ( !empty($newPwd1) && !empty($newPwd2) )
{
if ( strcmp($newPwd1,$newPwd2)!=0 )
{
$update_msg.= '<b class="required">The new password cannot be confirmed.<br> The re-typed password was not equal. Please try again.</b><br>';
$good = false;
}
elseif ( (strcmp($newPwd1,$newPwd2)==0) && strlen($newPwd1) < 7)
{
$update_msg.= '<b class="required">The new password must be at least 7 characters long.<br> Please try again.</b><br>';
$good = false;
}
}
if ( empty($adEmail) )
{
$update_msg.= '<b class="required">Your email is required</b>';
$good = false;
}
elseif ( !empty($adEmail) && !verifyEmail($adEmail) )
{
$update_msg.= '<b class="required">The provided email address is not valid. <br> Please entered a valid email address.</b>';
$good = false;
}
if ( (!empty($adPhone) && strlen($adPhone)< 12) || (!empty($adPhone) && !verifyPhone($adPhone)) )
{
$update_msg.= '<b class="required">The Phone Number must be at least 10 characters long. <br>Use the format "604-555-1234"</b>';
$good = false;
}
// If NOT good then this section of code is avoided and header
// redirects successfully. However, if everything is good and
// this section is executed then header at the end will not
// redirect. This script works fine because when $good is True
// and the updates takes place all the session vars are set
// including $update_msg. If I hit the back button everything is
// there but header wont take me there
if ($good)
{
$id=$HTTP_SESSION_VARS['userID'];
$admin=new Admin();
if ($admin->update ($id,$oldPwd,$newPwd1,$adPhone,$adEmail))
{
$HTTP_SESSION_VARS['user'] = $admin->getAdminName();
$HTTP_SESSION_VARS['userID'] = $admin->getAdminId();
$HTTP_SESSION_VARS['loginID']= $admin->getAdminUId();
$HTTP_SESSION_VARS['email'] = $admin->getAdminEmail();
$HTTP_SESSION_VARS['phone'] = $admin->getAdminPhone();
$update_msg = '<b class="required"><br>SUCCESS</b>';
}
else
{
$update_msg = '<b class="required">The Update failed. <br>Verify you password and try again</b>';
}
}
$HTTP_SESSION_VARS['update_msg'] = $update_msg;
header("Location: my_settings.php");
?>