forked from sterben04/Railway
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup-action.php
49 lines (36 loc) · 1.27 KB
/
signup-action.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
<?php
session_start();
$phone = "";
$name = "";
$errors = array();
$db=mysqli_connect('localhost','root','admin','Railway') or die("Sorry unable to connect to database");
if(isset($_POST['reg_user']))
{
$name = mysqli_escape_string($db,$_POST["name"]);
$phone = mysqli_escape_string($db,$_POST["phone"]);
$license = mysqli_escape_string($db,$_POST["license"]);
$password = mysqli_escape_string($db,$_POST["password"]);
if(empty($name))
array_push($error,"Name is required");
if(empty($phone))
array_push($error,"Phone number is required");
if(empty($password))
array_push($error,"Password is required");
$check_query = "SELECT * FROM Credentials WHERE phone = '$phone' LIMIT 1";
$result = mysqli_query($db,$check_query);
$user = mysqli_fetch_assoc($result);
if($user)
{
if($user["phno"] === $phno )
array_push($errors,"Phone number already registered" );
}
if(count($errors) == 0)
{
$password=md5($password);
$query = "INSERT INTO Credentials (id,phone,display_name,password,license) VALUES ('$phone','$name','$password','$license')" ;
mysqli_query($db,$query);
$_SESSION['phone'] = $phone
$_SESSION['success'] = "You have succesfully logged in!!!";
header("location: dash.php");
}
}