1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <?php
function absolute_url($page='index1.php'){
$url='http://' .$_SERVER['HTTP_POST'] .
dirname($_SERVER['PHP_SELF']);
$url=rtrim($url, '/\\');
$url .= '/' . $page;
return $url;
}
function check_login($dbc, $email='', $pass=''){
$errors=array();
if (empty($email)){
$errors[]='You forgot to enter your email address.';
} else {
$e= mysqli_real_escape_string($dbc,trim ($email));
}
if (empty ($pass)){
$errors[]= 'Your forgot to enter your password.';
}
else {
$p=mysqli_real_escape_string($dbc, trim ($pass));
}
if (empty($errors)){
$q="SELECT user_id, first_name FROM users WHERE email='$e' AND pass=SHA1('$p')";
$r=@mysqli_query($dbc, $q);
if (mysqli_num_rows($r) == 1){
$row=mysqli_fetch_array($r, MYSQLI_ASSOC);
return array(true, $row);
} else {
$errors[]='The email address and password entered do not match those on file.';
}
}
return array(false, $errors);
}
?> |