-
Notifications
You must be signed in to change notification settings - Fork 13
/
register.php
115 lines (98 loc) · 3.05 KB
/
register.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
include('dbconnect.php');
$f_name=$_POST['f_name'];
$l_name=$_POST['l_name'];
$email=$_POST['email'];
$password=md5($_POST['password']);
$mobile=$_POST['mobile'];
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$name = "/^[A-Z][a-zA-Z ]+$/";
$emailValidation = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9]+(\.[a-z]{2,4})$/";
$number = "/^[0-9]+$/";
if(empty($f_name) || empty($l_name) || empty($email) || empty($password) || empty($mobile) || empty($address1) || empty($address2)){
echo "<div class='alert alert-danger alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button>Please fill all the fields!</div>";
exit(0);
}
else{
if(!preg_match($name,$f_name)){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>First name is not valid..!</b>
</div>
";
exit();
}
if(!preg_match($name,$l_name)){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>Last name is not valid..!</b>
</div>
";
exit();
}
if(!preg_match($emailValidation,$email)){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>Email is not valid..!</b>
</div>
";
exit();
}
if(strlen($password) < 9 ){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>Password is weak</b>
</div>
";
exit();
}
if(!preg_match($number,$mobile)){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>Mobile number $mobile is not valid</b>
</div>
";
exit();
}
if(!(strlen($mobile) == 10)){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>Mobile number must be 10 digits</b>
</div>
";
exit();
}
//check for available user-details
$sql = "SELECT user_id FROM user_info WHERE email = '$email' LIMIT 1" ;
$check_query = mysqli_query($conn,$sql);
$count_email = mysqli_num_rows($check_query);
if($count_email > 0){
echo "
<div class='alert alert-danger'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>Email Address is already available Try Another email address</b>
</div>
";
exit();
}
else {
$sql="INSERT INTO user_info (first_name, last_name, email, password, mobile, address1, address2) VALUES ('$f_name','$l_name','$email','$password','$mobile','$address1','$address2')";
$run_query=mysqli_query($conn,$sql);
if($run_query){
echo "
<div class='alert alert-success'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
Click <b><a href='index.php'>here</a></b> to login.
</div>
";
}
}
}
?>