PhpSnip.com

User Stats

Simple Auth Code

Simple Auth Code For PHP4

Info

 Download  View Source (print view)
 Rating : 4.7  Views : 578

Source Code ( 31 lines )

<?
# Simple Auth For PHP4
# I use mysql but you can change this to what ever you want to. 


# Reject All Anonymous Logins
if((!$_POST[var_username]) || (!$_POST[var_password])){
header("Location: http://some_file_or_address_here");
exit;
}

# Run Query
$sql = mysql_query("select * from Table where Username='$_POST[var_username]' and Password='$_POST[var_password]'") or die (mysql_error());
$get = mysql_numrows($sql);

if($get == "1"){
print("Auth Granted");
} else { $get="3"; }


if($get == "0"){
print("Auth False");
} else { $get="3"; }

if($get == "3"){
print("Log there ip or run some statement here. Dont just let them off the hook.");
}



?>

Search

Subscribe

  Rss Feeds

Sponsors

Advertise