Hi there,
I was asked to make a little presentation. That’s done and all is well…
The tricky part is that they want to have a login/pass to access the page.
Even trickier is that the password is to work only once.
I dug around and found this php script. Form the sound of it, it works.
I’m not sure how to implement it. I have some SQL and PHP experience, but I think I could use a hand in getting this to run.
thanks!
<?php require_once('Connections/rsLogin.php');?>
<?php
// *** Validate request to login to this site.
session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "http://www.yahoo.com";
$MM_redirectLoginFailed = "http://www.google.com";
$MM_redirecttoReferrer = false;
mysql_select_db($database_rsLogin.php, $rsLogin.php);
$LoginRS__query=sprintf("SELECT username, password FROM login WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc()? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc()? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $rsLogin.php) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
$RemoveRS__query=sprintf("DELETE FROM login WHERE username='%s' AND password='%s' LIMIT 1",
get_magic_quotes_gpc()? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc()? $password : addslashes($password));
mysql_query($RemoveRS__query, $rsLogin.php) or die(mysql_error());
//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;
//register the session variables
session_register("MM_Username");
session_register("MM_UserGroup");
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<html>
<head>
</head> <body>
<form action="<?php echo $loginFormAction;?>" method="POST" name="login" id="login">
<p>username
<input name="username" type="text" id="username">
</p>
<p>password
<input name="password" type="text" id="password">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>