-
Notifications
You must be signed in to change notification settings - Fork 57
/
signup_script.php
36 lines (28 loc) · 976 Bytes
/
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
<?php
require "includes/common.php";
session_start();
$email = $_POST['eMail'];
$email = mysqli_real_escape_string($con, $email);
$pass = $_POST['password'];
$pass = mysqli_real_escape_string($con, $pass);
$pass = md5($pass);
$first = $_POST['firstName'];
$first = mysqli_real_escape_string($con, $first);
$last = $_POST['lastName'];
$last = mysqli_real_escape_string($con, $last);
$query = "SELECT * from users where email_id='$email'";
$result = mysqli_query($con, $query);
$num = mysqli_num_rows($result);
if ($num != 0) {
$m = "Email Already Exists";
header('location: index.php?error=' . $m);
} else {
$quer = "INSERT INTO users(email_id,first_name,last_name,password) values('$email','$first','$last','$pass')";
mysqli_query($con, $quer);
echo "New record has id: " . mysqli_insert_id($con);
$user_id = mysqli_insert_id($con);
$_SESSION['email'] = $email;
$_SESSION['user_id'] = $user_id;
header('location:products.php');
}
?>