Jump to content

[SOLVED] alter box


bhavin_85

Recommended Posts

hey guys

 

ive written this if statement and i want an alter box to appear when the wrong username and password is entered...however i also want the page to redirect the user to the login page once they click ok the to alter

 

if($count==1){
$_SESSION['username']=$username;
header("Location:default.php");
}
else {
echo "<script>alert('You have entered an Incorrect Username or Password')</script>";
header("Location:login.php");
}

the only problem is that the echo is modifying the header so it wont redirec, i get this error :

 

Warning: Cannot modify header information - headers already sent by (output started at /export/SOI-1/students/u2003/gy478/web/login1.php:13) in /export/SOI-1/students/u2003/gy478/web/login1.php on line 14

like 13 is the alter and line 14 is the header

 

any ideas how i can get around this?

 

Link to comment
https://forums.phpfreaks.com/topic/45870-solved-alter-box/
Share on other sites

If you will comment this line

echo "<script>alert('You have entered an Incorrect Username or Password')</script>";

Then the error will be gone.

 

My sugession is do like this

--------------------------

header("Location:login.php?login=fail");

and at login file set

if($_GET['login'] == "fail"){

    echo "<script>alert('You have entered an Incorrect Username or Password')</script>";

}

 

Link to comment
https://forums.phpfreaks.com/topic/45870-solved-alter-box/#findComment-222846
Share on other sites

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.