SVC Posted April 7, 2007 Share Posted April 7, 2007 Hi, I have my login script for clients to login to my site. They have to put thier email address in and then the password. The situation is that i want to add a Master password so we can use the clients email addres and a deafult password so we can login to their account when they have problems and need help. My script is below, any help would be good as i have spend alot of time on it and not got anywhere. ------------------------------------------------------------------- <? include("../config.php"); include("../sessions.php"); $_SESSION['session_id']=updateSession($_SESSION['session_id']); $msg=""; if ($_GET['logout']==1) { logout($_SESSION['session_id']); $msg="<div align=\"center\" class=\"bold\">You have successfully logged out</div>"; } if ($_SESSION['session_id']) { header("location:account.php"); exit; } if (isset($_POST['email'])) { //Process login $password=md5($_POST['password']); $_SESSION['session_id']=login($_POST['email'],$password); if ($_SESSION['session_id']) { if (!empty($_SESSION['return_page'])) { $rp=$_SESSION['return_page']; $_SESSION['return_page']=""; header("location: $rp"); } else { header("location: account.php"); } exit; } else { $msg="<div align=\"center\" class=\"red bold\">Invalid email or password</div>"; } } if ($_SESSION['session_id']) { if (!empty($_SESSION['return_page'])) { $page=$_SESSION['return_page']; $_SESSION['return_page']=""; } else { $page="location:account.php"; } header($page); exit; } ?> ---------------------------------------------------------------- Thanks very much Link to comment https://forums.phpfreaks.com/topic/46050-master-password-for-login/ Share on other sites More sharing options...
clown[NOR] Posted April 13, 2007 Share Posted April 13, 2007 add access levels 1 = Normal user 2 = Moderator 3 = Admin something like that Link to comment https://forums.phpfreaks.com/topic/46050-master-password-for-login/#findComment-228339 Share on other sites More sharing options...
youneek Posted April 15, 2007 Share Posted April 15, 2007 You might also just make an if statement that says if session = admin session then {full access}else {normal authentication method} Link to comment https://forums.phpfreaks.com/topic/46050-master-password-for-login/#findComment-229474 Share on other sites More sharing options...
GreenWithEnvy Posted April 15, 2007 Share Posted April 15, 2007 In your login function before you query the database, run a quick if() statement to see if password = master password. If so, then skip rest of steps and set login = success for that username. Link to comment https://forums.phpfreaks.com/topic/46050-master-password-for-login/#findComment-229523 Share on other sites More sharing options...
SVC Posted April 16, 2007 Author Share Posted April 16, 2007 Hi guys, thanks for the ideas, i have been trying to add the if() statement in but everytime i do it rejects the password. We dont have user levels, the Admin section is in a different directory which is protected by .htaccess I dont know why a simple thing is proving difficult. SVC Link to comment https://forums.phpfreaks.com/topic/46050-master-password-for-login/#findComment-230305 Share on other sites More sharing options...
SVC Posted April 22, 2007 Author Share Posted April 22, 2007 HI, i have added the if statement in, but i just get a blank screen now, i cant see where i am going wrong. My code as it is now. <? include("../config.php"); include("../sessions.php"); $_SESSION['session_id']=updateSession($_SESSION['session_id']); $msg=""; if ($_GET['logout']==1) { logout($_SESSION['session_id']); $msg="<div align=\"center\" class=\"bold\">You have successfully logged out</div>"; } if ($_SESSION['session_id']) { header("location:account.php"); exit; } if (isset($_POST['email'])) { //Process login if $password=md5($_POST['password']); $password=masterpassword($_POST['password']); header("location: account.php"); else $_SESSION['session_id']=login($_POST['email'],$password); if ($_SESSION['session_id']) { if (!empty($_SESSION['return_page'])) { $rp=$_SESSION['return_page']; $_SESSION['return_page']=""; header("location: $rp"); } else { header("location: account.php"); } exit; } else { $msg="<div align=\"center\" class=\"red bold\">Invalid email or password</div>"; } } if ($_SESSION['session_id']) { if (!empty($_SESSION['return_page'])) { $page=$_SESSION['return_page']; $_SESSION['return_page']=""; } else { $page="location:account.php"; } header($page); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/46050-master-password-for-login/#findComment-235510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.