forked from ELDHOSE104/sonline
/
signin.php
41 lines (31 loc) · 894 Bytes
/
signin.php
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
<?php
require_once("db.class.php");
$db=new DB($base,$server,$user,$pass);
if(isset($_POST['email']))
{
try
{
$email=$_POST['email'];
$password=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$email = stripslashes($email);
$password = stripslashes($password);
$email = mysql_real_escape_string($email);
$password = mysql_real_escape_string($password);
if($db->countOf('user',"email='$email' and password='$password'")==1)
{
session_start();
$_SESSION['user']=$db->queryUniqueValue("select id from user where email='$email' and password='$password'");
header("location: index.php");
}
else
{
echo '<script type="text/javascript"> alert("username of password is wrong please try again");window.location = "'.$_SERVER["HTTP_REFERER"].'";</script>';
}
}
catch(Exception $ex)
{
echo 'some errors occured)';
}
}
?>