| | |
PHP for login authentication
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2006
Posts: 19
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2006
Posts: 138
Reputation:
Solved Threads: 2
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.
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.
![]() |
Similar Threads
- html/php form for .htaccess validation (PHP)
- problems with sessions and login.php (PHP)
- PHP .htaccess form (PHP)
- PHP .tpl format template help! URGENT! (PHP)
- php help needed for login (PHP)
Other Threads in the PHP Forum
- Previous Thread: Variable typing in PHP?
- Next Thread: Need php script
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





