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
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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.