blui Posted March 27, 2007 Share Posted March 27, 2007 Hi all, I have a php login script that used to work fine but now it appears to not working correctly - I am assuming its down to the register_globals being now off. Can some please tell me what i need to do to get ths script working again please? <? session_start(); ob_start(); session_register(logged); $_SESSION['logged'] = 0; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <? $redirect = $_GET['redirect']; if (isset($_POST['submit'])) { if ($_POST['username'] == "Paul" && $_POST['password'] == "daleragu")// replace this logic with authorization from mysql if needed {//if it gets to this point, the authorization is correct, the we can redirect with the header 3 lines down $redirect = $_POST['redirect']; $_SESSION['logged'] = 1; header ("Location: $redirect"); } else { ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br><br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Login"> </form> </table> <? } } else { ?> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password<br><br> <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Login"> </form> </table> <? } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/44537-solved-re-login-script-not-working/ Share on other sites More sharing options...
papaface Posted March 27, 2007 Share Posted March 27, 2007 use [*code][*/code] tags! Link to comment https://forums.phpfreaks.com/topic/44537-solved-re-login-script-not-working/#findComment-216308 Share on other sites More sharing options...
blui Posted March 27, 2007 Author Share Posted March 27, 2007 how and where would I use the [*code][*/code] tags any clarification would be a great help, Thanks blu Link to comment https://forums.phpfreaks.com/topic/44537-solved-re-login-script-not-working/#findComment-216413 Share on other sites More sharing options...
JayLewis Posted March 27, 2007 Share Posted March 27, 2007 <? session_start(); ob_start(); session_register(logged); $_SESSION['logged'] = 0; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <? $redirect = $_GET['redirect']; if (isset($_POST['submit'])) { if ($_POST['username'] == "Paul" && $_POST['password'] == "daleragu")// replace this logic with authorization from mysql if needed {//if it gets to this point, the authorization is correct, the we can redirect with the header 3 lines down $redirect = $_POST['redirect']; $_SESSION['logged'] = 1; header ("Location: $redirect"); } else { ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" name="submit" value="Login"> </form> </table> <? } } else { ?> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" name="submit" value="Login"> </form> </table> <? } ?> done it for you. Link to comment https://forums.phpfreaks.com/topic/44537-solved-re-login-script-not-working/#findComment-216415 Share on other sites More sharing options...
blui Posted March 27, 2007 Author Share Posted March 27, 2007 Thanks JayLewis, I tried your code and still recieved the following error messages any idea why? Notice: Use of undefined constant logged - assumed 'logged' in f:\program files\easyphp1-7\www\php\adminloginstart.php on line 4 Notice: Undefined index: redirect in f:\program files\easyphp1-7\www\php\adminloginstart.php on line 9 Link to comment https://forums.phpfreaks.com/topic/44537-solved-re-login-script-not-working/#findComment-216422 Share on other sites More sharing options...
per1os Posted March 27, 2007 Share Posted March 27, 2007 <?php session_start(); ob_start(); session_register('logged'); // add single quotes to avoid the constant stuff. $_SESSION['logged'] = 0; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <? $redirect = isset($_POST['redirect'])?$_POST['redirect']:null; // added a check here to avoid the index error. also changed to POST. if (isset($_POST['submit'])) { if ($_POST['username'] == "Paul" && $_POST['password'] == "daleragu")// replace this logic with authorization from mysql if needed {//if it gets to this point, the authorization is correct, the we can redirect with the header 3 lines down $redirect = $_POST['redirect']; $_SESSION['logged'] = 1; header ("Location: $redirect"); } else { ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" name="submit" value="Login"> </form> </table> <? } } else { ?> <table width="502" border="0" align="center" cellpadding="5" cellspacing="0" class="h3"> Invalid Username and/or Password <form action="adminloginstart.php" method="post"> <input type="hidden" name="redirect" value="<? echo $redirect; ?>"> Username: <input type="text" name="username"> Password: <input type="password" name="password"> <input type="submit" name="submit" value="Login"> </form> </table> <? } ?> Link to comment https://forums.phpfreaks.com/topic/44537-solved-re-login-script-not-working/#findComment-216423 Share on other sites More sharing options...
blui Posted March 27, 2007 Author Share Posted March 27, 2007 Thanks all that seems to be working fine now, cheers greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/44537-solved-re-login-script-not-working/#findComment-216428 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.