-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignupProcess.php
60 lines (49 loc) · 1.87 KB
/
signupProcess.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
<?php
include "connection.php";
$fname = $_POST["f"];
$lname = $_POST["l"];
$email = $_POST["e"];
$password = $_POST["p"];
$mobile = $_POST["m"];
$gender = $_POST["g"];
if(empty($fname)){
echo ("Please Enter Your First Name.");
}else if(strlen($fname) > 50){
echo ("First Name Must Contain LOWER THAN 50 characters.");
}else if(empty($lname)){
echo ("Please Enter Your Last Name.");
}else if(strlen($lname) > 50){
echo ("Last Name Must Contain LOWER THAN 50 characters.");
}else if(empty($email)){
echo ("Please Enter Your Email Address.");
}else if(strlen($email) > 100){
echo ("Email Address Must Contain LOWER THAN 100 characters.");
}else if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
echo ("Invalid Email Address.");
}else if(empty($password)){
echo ("Please Enter Your Password.");
}else if(strlen($password) < 5 || strlen($password) > 20){
echo ("Password Must Contain 5 to 20 Characters.");
}else if(empty($mobile)){
echo ("Please Enter Your Mobile Number.");
}else if(strlen($mobile) != 10){
echo ("Mobile Number Must Contain 10 characters.");
}else if(!preg_match("/07[0,1,2,4,5,6,7,8]{1}[0-9]{7}/",$mobile)){
echo ("Invalid Mobile Number.");
}else{
$rs = Database::search("SELECT * FROM `user` WHERE `email`='".$email."' OR `mobile`='".$mobile."'");
$n = $rs->num_rows;
if($n > 0){
echo ("User with the same Email Address or same Mobile Number already exists.");
}else{
$d = new DateTime();
$tz = new DateTimeZone("Asia/Colombo");
$d->setTimezone($tz);
$date = $d->format("Y-m-d H:i:s");
Database::iud("INSERT INTO `user`
(`fname`,`lname`,`email`,`password`,`mobile`,`joined_date`,`gender_gender_id`,`status_status_id`) VALUES
('".$fname."','".$lname."','".$email."','".$password."','".$mobile."','".$date."','".$gender."','1')");
echo ("success");
}
}
?>