-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
65 lines (55 loc) · 1.34 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
session_start();
include 'DBConn.php';
$first = $_POST['first'];
$last = $_POST['last'];
$Email = $_POST['Email'];
$pwd = $_POST['pwd'];
if(empty($first)){
header("Location: main.php?id=first");
exit();
}
else{
if (!preg_match("/^[a-zA-Z ]*$/",$first)){
header("Location: main.php?id = Invalid_Name");
exit();
}
}
if(empty($last)){
header("Location: main.php?id=last");
exit();
}
if(empty($Email)){
header("Location: main.php?id=email");
exit();
}
else{
if (!filter_var($Email, FILTER_VALIDATE_EMAIL)){
header("Location: main.php?id=invalid_mail");
exit();
}
}
if(empty($pwd)){
header("Location: main.php?id=password");
exit();
}
else{
if(strlen($pwd)<8){
header("Location: main.php?id=pasword_atleast_8");
exit();
}
}
$sql_mail = "SELECT Email FROM user WHERE Email='$Email' ";
$res = $conn->query($sql_mail);
$check_mail = mysqli_num_rows($res);
if($check_mail == 1){
header("Location: main.php?error=Email");
exit();
}
else{
//$hidden_pass = password_hash($pwd, PASSWORD_DEFAULT);
$pwd = md5($pwd);
$sql = "INSERT INTO user(first, last, Email, pwd) VALUES ('$first', '$last', '$Email', '$pwd') ";
$show = $conn->query($sql);
header("Location: main.php");
}