-
Notifications
You must be signed in to change notification settings - Fork 1
/
signupphp.php
127 lines (104 loc) · 2.25 KB
/
signupphp.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
117
118
119
120
121
122
123
124
125
126
<?php
session_start();
?>
<?php
include 'dbconnect.php'
?>
<?php
if(isset($_SESSION['login'])){
header("location:http://192.168.121.187:8001/anjali/index.php");
}
$emptyname="";
$name="";
$emptyno="";
$number="";
$email="";
$gender="";
$emptygender="";
$invalidname="";
$wrong="";
$password="";
$confirm="";
$invalidno="";
$emptyusername="";
$storesession="";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if(empty($_POST["username"]))
{
$emptyusername="valid username is required";
$storesession="";
}
else
{
$username=check($_POST["username"]);
$username=trim($username);
if(isset($_POST['username']))
{
$username=$_POST['username'];
$checkdata=" SELECT username FROM anjali_signup WHERE username='$username' ";
$query=mysqli_query($con,$checkdata);
if(mysqli_num_rows($query)>0)
{
echo "User Name Already Exist";
$storesession="";
}
else
$storesession=1;
}
}
if(empty($_POST["name"]))
{ $emptyname="name is required";
$storesession="";
}
else
$name=check($_POST["name"]);
if(!preg_match ('/^([a-zA-Z]+)$/', $name))
{
$invalidname="enter letters only";
$storesession="";
}
if(empty($_POST["phone_no"]))
{
$emptyno="number is required";
$storesession="";
}
else
{
$number=check($_POST["phone_no"]);
if(!preg_match("/^[0-9]{10}$/", $number))
{
$invalidno="enter a valid no";
$storesession="";
}
}
$email=check($_POST["field"]);
$gender=check($_POST["gender"]);
$password1=check($_POST["password"]);
$confirm=check($_POST["coord"]);
$password=md5($password1);
if($password1!=$confirm)
{
$wrong="Enter same passwords";
}
else
{
if($storesession)
{
$_SESSION["username"]=$username;
$_SESSION["signup"]=true;
mysqli_query ($con,"INSERT INTO anjali_signup(username,name,mobile_no,email,gender,password)
values
('$username','$name','$number','$email','$gender','$password')");
mysqli_close($con);
//echo $_SESSION["username"];
header('Location:http://192.168.121.187:8001/anjali/profilepage.php');
}
}
}
function check($value)
{
$value= htmlspecialchars($value);
return $value;
}
?>