Howcome in PHP, my Header("Location:") skips EVERYTHING?

livingwater8425

New member
Hi,

I have a php conditional, and if the conditional is met, it supposed to pop up a js dialog box, tell the user they failed, and then redirect the page with header ("location:") function. But it's really weird that once i put down the header function, once user submit the form that meets that conditional, it will directly redirect the page, without pop up the dialog box.

not even dialog box, it seems ignored all my previous conditionals, it just ignored everything ahead of it, seems it does not follow order of the lines anymore. it even changed my login button which is using another header function to redirect to another page. Something wrong with the submit buttons?

Here is part of the code:

if($emailcheck != 0)
{


?>

<script language=JavaScript>
alert("An account with that email already exists. Registraion Failed.")
frm.email.focus()
</script>

<?php



header( "Location: ./new_user.php" );


}



Thanks, Please help!!!
@David

Thanks, but it gave me error: Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\reseller_portal\redirect.php:3) in C:\xampp\htdocs\reseller_portal\redirect.php on line 4


and by the way, redirect.php should be in a separate file by its own right?
 
Back
Top