/
register.php
69 lines (51 loc) · 1.61 KB
/
register.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
require_once("db.class.php");
$db=new DB($base,$server,$user,$pass);
if(isset($_POST['email']))
{
try
{
$_name=$_POST['full_name'];
$_name=stripslashes($_name);
$_name=mysql_real_escape_string($_name);
$_email=$_POST['email'];
$_email=stripslashes($_email);
$_email=mysql_real_escape_string($_email);
$_password=$_POST['password'];
$_password=stripslashes($_password);
$_password=mysql_real_escape_string($_password);
$_phno=$_POST['phno'];
$_phno=stripslashes($_phno);
$_phno=mysql_real_escape_string($_phno);
$_college=$_POST['college'];
$_college=stripslashes($_college);
$_college=mysql_real_escape_string($_college);
$result=$db->query("select * from user where email='$_email'");
if($db->fetchNextObject($result))
{
echo'<script type="text/javascript"> alert("email already registered try sign in");window.location = "'.$_SERVER["HTTP_REFERER"].'";</script>';
}
else
{
$result=$db->query("select * from user where phno=$_phno");
if($db->fetchNextObject($result))
{
echo'<script type="text/javascript"> alert("phone number already registered try sign in");window.location = "'.$_SERVER["HTTP_REFERER"].'";</script>';
}
else
{
$result=$db->execute("insert into user values(DEFAULT,'$_email','$_password','$_name',$_phno,'$_college',NOW())",false);
//added line
$result=$db->execute("insert into user_level values(DEFAULT,'1',NOW())",false);
session_start();
$_SESSION['user']=($db->maxOfAll("id","user"));
header("location: index.php");
}
}
}
catch(Exception $ex)
{
echo "something went wrong";
}
}
?>