Ja, ali lahko na hitro pogledaš in poveš kje je napaka.
<?php
include ('config.php');
// convert posted info to easy to use variables
$user = $_REQUEST['username'];
$pass = $_REQUEST['password'];
// strip away any dangerous tags
$user=strip_tags($user);
$pass=strip_tags($pass);
// remove spaces from variables
$user=str_replace(" ","",$user);
$pass=str_replace(" ","",$pass);
// remove escaped spaces
$user=str_replace("%20","",$user);
$pass=str_replace("%20","",$pass);
// add slashes to stop hacking
$user=addslashes($user);
$pass=addslashes($pass);
// hash password into md5 (random 32 characters - md5)
$pass=md5($pass);
// search database to check for user
$request = "SELECT * FROM aegnor_users WHERE password='".$pass."' AND username='".$user."'";
// hand over the request
$results = mysql_query($request);
// if mysql returns any number of rows great than 0 then there is a succesful login
if(mysql_num_rows($results))
{
// get users id
$getid = "SELECT * FROM aegnor_users WHERE username='".$user."' LIMIT 1";
$getidexec = mysql_query($getid);
while($r=mysql_fetch_array($getidexec)){
$userid = $r[userid];
}
// set a cookie
setcookie( "userid", "$userid", time()+3600, "/", "", 0 );
echo "Prijava uspešna.<br><br><a href="index.php">Continue...</a>";
}
else // only happens if not a succesful username and password match
{
// login failed so display error message and kill script
die("Uporabniško ime ali geslo je napačno!");
}
?>