Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Ive got this register script that puts the information into a mysql database. now it all works fine and when someone does something wrong its says the error (e.g. "Username not defined")

but when it goes wrong it does not look very good because it just displays the message on an empty page, so i thought i would make it redirect to the form page and display the message there.

here is the working script

$forename = $_POST['forename'];      
$surname = $_POST['surname'];       
$email = $_POST['email'];    
$password = $_POST['password'];    
$username = $_POST['username'];

$errors = array();

 if(!$username) {

    $errors[] = "Username is not defined";

 }

 if(!$password) {

    $errors[] = "Password is not defined";

 }

and it continues.

now i just thought i could do this

 $errors = array();

 if(!$username) {

    $errors[] = header( 'Location: http://localhost/muiltabledistractions/#!/page_register_error-Username-is-not-defined' ) ;

 }

 if(!$password) {

    $errors[] = "Password is not defined";

 }

but no, all it does is ignore it.

could someone please help me

please feel free to ask for more of the script if you need it

many thanks connor

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
238 views
Welcome To Ask or Share your Answers For Others

1 Answer

You cannot wrap a header in a array like that.

You just call the function, then it redirects.

header( 'Location: http://localhost/muiltabledistractions/#!/page_register_error-Username-is-not-defined' ) ;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...