Jump to content

master password for login


SVC

Recommended Posts

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

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

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;

}

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.