Jump to content

how would i get multiple header functions?


yobo

Recommended Posts

Hey all,  how would go about having a header function in an if statment? what I would like to do is redirect user to sucess page if data was added if not have the user redirected to fail page, my coding is shown below. becuase if I do add the header function with the if statments it gives me an error messege.

 

<?php header("location: sucess.php");

include 'db.php';

include 'function.php';

 

if(!isset($_POST['register'])) {

 

 

 

} else {

 

  //init error variables

  $errorusername = false;

  $erroremail = false;

  $erroremailconf = false;

  $errorpassword = false;

  $errorpassconf = false;

 

  $username = isset($_POST['username']) ? trim($_POST['username']) : '';

  $email = isset($_POST['email']) ? trim($_POST['email']) : '';

  $emailconf = isset($_POST['emailconf']) ? trim($_POST['emailconf']) : '';

  $password = isset($_POST['password']) ? trim($_POST['password']) : '';

  $passconf = isset($_POST['passconf']) ? trim($_POST['passconf']) : '';

 

  if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $erroremail = true;

  if(strlen($username) == '0') $errorusername = true;

  if(strlen($emailconf) == '0') $erroremailconf = true;

  if(strlen($password) == '0') $errorpassword = true;

  if(strlen($passconf) =='0') $errorpassconf = true;

 

  //display form again

  if($errorusername || $erroremail || $erroremailconf || $errorpassword || $errorpassconf) {

      showForm($errorusername,$erroremail,$erroremailconf,$errorpassword,$errorpassconf);

 

  } else {

     

      //check user email

     

      $query = mysql_query("SELECT email FROM users WHERE email = '".$email."'");

      if(@mysql_query($query)) $erroremail = true;

     

            $query2 = "INSERT INTO users SET

              username='$username',

              password='$password',

              email='$email'";

             

             

      if(@mysql_query($query2)) {

        header("location: good.php");

        }else{

            header("location: bad.php");

            } 

           

       

       

     

      }

     

 

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.