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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.