Zend - The PHP Company




Security

Add Code


Simple Auth Code  

Type: code fragment
Added by: Dataphix
Entered: 19/06/2003
Last modified: 06/12/2002
Rating: - (fewer than 3 votes)
Views: 5367
Simple Auth Code For PHP4



<?
# 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.");
}



?>








Usage Example


See the example


Rate This Script





Search



This Category All Categories