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 38 39 40 41 42 43 44 45 46
|
<?php
session_start();
include('conn.php');
if(isset($_POST['conn']))
{
$cnx = open();
$email = strtolower($_POST['login']);
$pwd = md5($_POST['pwd']);
$cookie = $_POST['cook'];
$result = mysql_query(" SET @rep = '0';",$cnx);
$result = mysql_query("CALL sp_auth_ID('".mysql_escape_string($email)."','".mysql_escape_string($pwd)."','2',@rep);", $cnx);
$result = mysql_query("SELECT @rep as tt;", $cnx);
if (!$result)
{
die(mysql_error($cnx));
}
$row = mysql_fetch_assoc($result);
$id = $row["tt"];
if($id > 0)
{
$_SESSION['email'] = $email;
$_SESSION['pwd']= $pwd;
$_SESSION['id'] = $id;
echo 'valid';
if($cookie == 'true')
{
setcookie("email", $email);
setcookie("pwd", $pwd);
setcookie("id", $id);
}
}
else
{
echo 'invalid';
}
close();
}
?> |