-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaSignup.php
145 lines (115 loc) · 3.9 KB
/
aSignup.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
include("connection.php");
function check_login($con)
{
if(isset($_SESSION['user_id']))
{
$id = $_SESSION['user_id'];
$query = "select * from users where user_id = '$id' limit 1";
$result = mysqli_query($con,$query);
if($result && mysqli_num_rows($result) > 0)
{
$user_data = mysqli_fetch_assoc($result);
return $user_data;
}
}
//redirect to login
header("Location: login.php");
die;
}
function random_num($length)
{
$text = "";
if($length < 5)
{
$length = 5;
}
$len = rand(4,$length);
for ($i=0; $i < $len; $i++) {
# code...
$text .= rand(0,9);
}
return $text;
}
if($_SERVER['REQUEST_METHOD'] == "POST")
{
//something was posted
$user_name = $_POST['user_name'];
$password = $_POST['password'];
$email = $_POST['email'];
$utype = $_POST['address'];
if(!empty($user_name) && !empty($password) && !is_numeric($user_name))
{
//save to database
$user_id = random_num(6);
$pnum = random_num(11);
// $address= random_bytes(6);
$query = "insert into customer (c_id,c_name,password,c_email,c_p_number,c_address) values ('$user_id','$user_name','$password','$email','$pnum','$utype')";
mysqli_query($con, $query);
header("Location: Home Page.html");
die;
}else
{
echo "Please enter some valid information!";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
/>
<title>Signup page</title>
<style>
h1{text-align: center;}
</style>
</head>
<body background="bg.jpeg">
<main>
<h1>Signup to MediSearch</h1> <br>
<section style="height: 470px;" class="container d-flex justify-content-center align-items-center rounded-3 " id="subscribe">
<div>
<br>
<form method='post'>
<div class="mb-4">
<label for="exampleInputEmail1" class="form-label">User name</label>
<input type="type" class="form-control" id="exampleInputEmail1" name="user_name">
</div>
<div class="mb-4">
<label for="exampleInputPassword1" class="form-label">Password</label>
<input type="password" name="password" class="form-control" id="exampleInputPassword1">
</div>
<div class="mb-4">
<label for="exampleInputPassword1" class="form-label">Email</label>
<input type="type" name="email" class="form-control" id="exampleInputPassword1">
</div>
<div>
<label for="exampleInputPassword1" class='form-label'>Address</label>
<input type="type" name="address" class="form-control" id="exampleInputPassword1">
</div>
<div>
<br>
<button type="submit" class="btn btn-primary">Sign Up</button>
<br> <br>
Already have an account?
<a href="login.php" class="de text-white">Click to Login</a>
</div>
<br>
</form>
</div>
</section>
</main>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"
></script>
</body>
</html>