PHP code question??? (Filler)?

AnonymousJohn

New member
If have this if statement:

if ( $mypassword != $passconf) {
?>
<script type='text/javascript' >
alert('The two passwords did not match!');
</script>
<?php
header("location:../register.php");
}

When the page runs after I register a user, if the passwords do not match, the header redirects the page, but I never see an alert...

Can someone help me with this problem?

Note: I have also tried putting the javascript inside an echo and that didnt work either
 
u closed the php tag before u put the end of the if statement so i think the rest will execute. y not use simple javascript for not only the redirecting script but also with the
if ( $mypassword != $passconf)
script.

or try:

<?php
if ( $mypassword != $passconf)
{
echo "alert('the passwords do not match')";
header("location: /register.php");
}
?>
 
You can't display content then do a header("location .. " as the header is a HTTP header which can only be sent to the browser before any content is sent.

Why not just do a javascript redirect instead?

window.location="/register.php";

?
 
double quotes in the alert

if ( $mypassword != $passconf) {
?>
<script type='text/javascript' >
alert("The two passwords did not match!");
</script>
<?php
header("location:../register.php");
}
 
Back
Top