View Single Post
  #27  
Old 04-16-2005, 12:17 AM
DevilDog#1 is offline DevilDog#1

Join Date: Jul 2002
Posts: 7,040

Interesting ... Try now

PHP Code:
<?
function login_form() {?>

    <form method="post" action="<? Echo($_SERVER['PHP_SELF']);?>">
    Username: <input type="text" name="username" /><br />
    Password: <input type="password" name="password" /><br />
    <input type="hidden" name="login" value="true" />
    <input type="submit" name="login" value=" Login " /> <input type="reset" value=" Reset " />
    </form>

<? }

If(
$_POST['login']) {

     
$username=mysql_real_escape_string($_POST['username']);
     
$password=mysql_real_escape_string($_POST['password']);
    
    
$query=mysql_query("SELECT * FROM users WHERE username='".$username."' AND password='".$password."' LIMIT 1");
    
    If(
mysql_num_rows($query) > 0) {
        
setcookie("loggedin","true",time+36000); //1 day
        
sleep(1);
    }
    
mysql_free_result($query);
    
    
header("Location: ".$_SERVER['PHP_SELF']);
    exit;
}

If(
$_COOKIE['loggedin']!="true") {

    Echo(
" You do not have permission to access this page. Please login Below. ");
    
login_form(); // print the login form
    
exit;
}
?>
__________________








Quote:
If I don't do that doesn't mean I can't - DD#1
Reply With Quote