-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_signup.php
79 lines (59 loc) · 2.07 KB
/
user_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
session_start();
$title = "User Signup";
require "./template/header.php";
require "./functions/database_functions.php";
$conn = db_connect();
$firstname = trim($_POST['firstname']);
$firstname = mysqli_real_escape_string($conn, $firstname);
$lastname = trim($_POST['lastname']);
$lastname = mysqli_real_escape_string($conn, $lastname);
$email = trim($_POST['email']);
$email = mysqli_real_escape_string($conn, $email);
$password = trim($_POST['password']);
$password = mysqli_real_escape_string($conn, $password);
$address = trim(trim($_POST['address']));
$address = mysqli_real_escape_string($conn, $address);
$city = trim($_POST['city']);
$city = mysqli_real_escape_string($conn, $city);
$zipcode = trim($_POST['zipcode']);
$zipcode = mysqli_real_escape_string($conn, $zipcode);
if(empty($firstname) || empty($lastname) || empty($email) || empty($password) || empty($address)||empty($city)||empty($zipcode))
{
header("Location:../med/signup.php?signup=empty");
}
else
{
if(!filter_var($email,FILTER_VALIDATE_EMAIL))
{
header("Location:../med/signup.php?signup=invalidemail");
}
else
{
$findUser = "SELECT * FROM customers WHERE email = '$email'";
$findResult = mysqli_query($conn, $findUser);
if(mysqli_num_rows($findResult)==0){
$insertUser = "INSERT INTO customers(firstname,lastname,email,address,password,city,zipcode) VALUES
('$firstname','$lastname','$email','$address','$password','$city','$zipcode')";
$insertResult = mysqli_query($conn, $insertUser);
if(!$insertResult)
{
echo "Can't add new user " . mysqli_error($conn);
exit;
}
$userid = mysqli_insert_id($conn);
header("Location: signin.php");
}
else
{
$row = mysqli_fetch_assoc($findResult);
$userid = $row['id'];
header("Location: signin.php");
}
}
}
?>
<?php
if(isset($conn)) {mysqli_close($conn);}
require_once "./template/footer.php";
?>