-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
executable file
·52 lines (47 loc) · 1.14 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
<?php
require "functions/db.php";
require "functions/users.php";
//echo"piyush";
if (isset($_POST["name"]))
{//$name = explode(" ",strip_tags(trim($_POST["name"])));
//$first_name = ucfirst($name[0]);
$first_name = ucfirst($name);
//if($name[1])
//$last_name = ucfirst($name[1]);
//else
//$last_name = '';
}
else
{echo 'Name not supplied';
exit();}
if (isset($_POST["mobile"]))
{if (is_numeric($_POST["mobile"]))
$mobile = $_POST["mobile"];
else
{
echo 'Mobile number is invalid';
exit();}
$sql = "SELECT user_id FROM users WHERE phone_number='$mobile' LIMIT 1";
$res = mysqli_query($conn,$sql);
$mobile_check = mysqli_num_rows($res);
if ($mobile_check > 0)
{echo 'Mobile number is already registered with us';
exit();}
}
else
{echo 'Mobile number is missing';
exit();}
if (isset($_POST["password"]))
$pass= md5($_POST["password"]);
else
{echo 'Password is missing';
exit();}
$sql = "INSERT INTO users (first_name, phone_number, password) VALUES ('$first_name', '$mobile', '$pass')";
$res = mysqli_query($conn,$sql);
if(!$conn->affected_rows)
echo 'Error in registeration. Please try again later.';
else
echo 'Success';
mysqli_close($conn);
exit();
?>