-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
50 lines (46 loc) · 1.69 KB
/
signup.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
<?php
require 'required.php';
if(isset($_POST['name']) && isset($_POST['uname']) && isset($_POST['password']) && isset($_POST['cpassword'])
&& isset($_POST['eid']) && isset($_POST['gender'])
&& isset($_POST['contact']) && isset($_POST['dob'])
&& isset($_POST['security']) && isset($_POST['ans']))
{
$name = htmlentities(mysql_real_escape_string($_POST['name']));
$username = htmlentities(mysql_real_escape_string($_POST['uname']));
$pass = md5($_POST['password']);
$cpass = $_POST['cpassword'];
$eid = $_POST['eid'];
$gender = $_POST['gender'];
$contact = $_POST['contact'];
$dob = strtotime($_POST['dob']);
$security = $_POST['security'];
$ans = trim(strtolower(htmlentities(mysql_real_escape_string($_POST['ans']))));
$query = "SELECT `username` FROM `login` WHERE `username` = '$username'";
if($query_run=mysql_query($query))
{
$query_num_rows = mysql_num_rows($query_run);
if($query_num_rows == 1)
{
echo '<script type=text/javascript> window.location.href="signup(form).php?message=2"; </script>';
//header("refresh :5;url=signupform.php");
}
else if($query_num_rows == 0)
{
$query = "INSERT INTO `login`
VALUES(NULL,'$username','$pass','$name','$contact','$dob',2,'$security','$ans','','$eid','$gender')";
if(!(mysql_query($query)))
{
echo mysql_error();
} else {
$lid = mysql_insert_id();
$_SESSION['user_id'] = $lid;
//creating record in student table
$query = "insert into student values(NULL, '$lid', '0', '0', '0', '')";
if(!(mysql_query($query)))
die(mysql_error());
echo '<script type="text/javascript"> window.location.href="signup_specific(form).php"; </script>';
}
}
}
}
?>