forked from vaishnavi17/thevector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup_script.php
47 lines (35 loc) · 1.13 KB
/
signup_script.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
<?php
session_start();
include "database_handler.php";
$first = $_POST['first'];
$last = $_POST['last'];
$uid = strtolower($_POST['uid']);
$email = strtolower($_POST['email']);
$pwd = $_POST['pwd'];
$class = $_POST['class'];
/*echo $first . $last . $uid . $class . $pwd . $class;*/
$sql = "SELECT * FROM user_table WHERE uid = '$uid'";
$result = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_assoc($result)) {
$user_name = $row['uid'];
$_SESSION['error_msg'] = "Username $user_name already exists! Please try again.";
header("Location:signup.php");
exit();
}
$sql = "SELECT * FROM user_table WHERE email = '$email'";
$result = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_assoc($result)) {
$email = $row['email'];
$_SESSION['error_msg'] = "User with email ID $email already exists! Please try again.";
header("Location:signup.php");
exit();
}
else {
$sql = "INSERT INTO user_table (first, last, uid, email, pwd, class)
VALUES ('$first', '$last', '$uid', '$email', '$pwd', '$class')";
$result = mysqli_query($conn, $sql);
$_SESSION['LoggedIn'] = true;
$_SESSION['UserName'] = $uid;
header("Location:index.php");
exit();
}