Php&SQL - one time access

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.


<?php require_once('Connections/rsLogin.php');?> 
// *** Validate request to login to this site. 
$loginFormAction = $_SERVER['PHP_SELF']; 
if (isset($accesscheck)) { 
$GLOBALS['PrevUrl'] = $accesscheck; 
if (isset($_POST['username'])) { 
$MM_fldUserAuthorization = ""; 
$MM_redirectLoginSuccess = ""; 
$MM_redirectLoginFailed = ""; 
$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 
if (isset($_SESSION['PrevUrl']) && false) { 
$MM_redirectLoginSuccess = $_SESSION['PrevUrl']; 
header("Location: " . $MM_redirectLoginSuccess ); 
else { 
header("Location: ". $MM_redirectLoginFailed ); 
</head> <body> 
<form action="<?php echo $loginFormAction;?>" method="POST" name="login" id="login"> 
<input name="username" type="text" id="username"> 
<input name="password" type="text" id="password"> 
<input type="submit" name="Submit" value="Submit">