-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcreate_cust.php
116 lines (110 loc) · 3.05 KB
/
create_cust.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
116
<?php
include "include/db.php";
if (isset($_POST["name"])) {
$name = $_POST["name"];
$id = $_POST["id"];
$email = $_POST['email'];
$password = $_POST['password'];
$repassword = $_POST['repassword'];
$mobile = $_POST['phoneno'];
$address = $_POST['address'];
$nameexp = "/^[a-zA-Z ]+$/";
$emailValidation = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9]+(\.[a-z]{2,4})$/";
$number = "/^[0-9]+$/";
if(empty($name) || empty($id) || empty($email) || empty($password) || empty($repassword) ||
empty($mobile) || empty($address)){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><b>PLease Fill all fields..!</b>
</div>
";
exit();
} else {
if(!preg_match($nameexp,$name)){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>this $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>this $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(strlen($repassword) < 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($password != $repassword){
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>password is not same</b>
</div>
";
}
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 digit</b>
</div>
";
exit();
}
//existing email address in our database
$sql = "SELECT custid FROM cust WHERE email_id = '$email' LIMIT 1" ;
$check_query = mysqli_query($con,$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 `cust`
(`custid`, `c_name`, `phoneno`, `c_address`, `email_id`, `password`)
VALUES ('$id', '$name', '$mobile', '$address',
'$email', '$password')";
if (mysqli_query($con, $sql)) {
echo "register_success";
} else {
echo "register_fail try with some onter user". mysqli_error($con);
}
}
}
}
?>