User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,554 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,603 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 836 | Replies: 1
Reply
Join Date: Aug 2006
Posts: 9
Reputation: tmv105 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tmv105 tmv105 is offline Offline
Newbie Poster

PHP for login authentication

  #1  
Feb 2nd, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Posts: 138
Reputation: php_daemon is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
php_daemon php_daemon is offline Offline
Junior Poster

Re: PHP for login authentication

  #2  
Feb 2nd, 2007
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:28 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC