943,935 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1643
  • PHP RSS
Feb 2nd, 2007
0

PHP for login authentication

Expand Post »
I have created a HTML form for a user to login that checks against a database of usernames and passwords to ensure authenticity.

If it's good to go, I redirect to a new page, but if it's not I am trying to display a message on my "Login" page and allow the user to re-enter a username and password. Below is what I am using...I included echo statements to me sure that I entered these. The problem lies in the "else". The 'redirect' is the name of a hidden tag on my form that I am assigning a value to if the 'else' portion is executed.

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
//echo "post redirect is " .$_POST['redirect'];
header("Location: " . $MM_redirectLoginSuccess );
}
else {
$_POST['redirect'] = 'invalid';
echo "t";
header("Location: ". $MM_redirectLoginFailed );

Then within my HTML I say this
<?php if(isset($_POST['redirect'])){ echo "<h4>HELP!</h4>"; }?>

As long as I have the 'echo' statement in the else, it displays "HELP". Why does it not do this as soon as take the echo out. BOGGLED!!!

Thanks to anyone who can help me figure this out!

Tara
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tmv105 is offline Offline
22 posts
since Aug 2006
Feb 2nd, 2007
0

Re: PHP for login authentication

You have echo "t"; which causes header() not to work, thus no redirect occurs (plus warning should be issued, you'd see it if you had error reporting on).

Also, are you trying to pass $_POST['redirect'] to another page? That won't work, $_POST is available only in the page the form is submitted to. Use session instead.
Reputation Points: 13
Solved Threads: 2
Junior Poster
php_daemon is offline Offline
138 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Variable typing in PHP?
Next Thread in PHP Forum Timeline: Need php script





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC