-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
66 lines (51 loc) · 1.67 KB
/
signup.php
File metadata and controls
66 lines (51 loc) · 1.67 KB
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
<?php
session_start();
// Checks if all the variable are recieved via POST method
if(isset($_GET['fullname']) && isset($_GET['email']) && isset($_GET['password']) && isset($_GET['address']) )
{
$fullname = $_GET['fullname'];
$email = $_GET['email'];
$u_password = $_GET['password'];
$address = $_GET['address'];
// Database connectivity.
require('generic_php/db_connect.php');
$conn= new db_connector;
$conn->coonect_now();
//BCRYPT is applied to generate hash key
$options = [ 'cost' => 12, 'salt' => "heykitheykitheykitheykit",];
$hash_pass = trim(password_hash($u_password, PASSWORD_BCRYPT, $options)."\n");
//If some one is already logged in
if(isset($_SESSION['register']))
{
echo "login";
}
else{
// Count occurance of email ID
$query="select * from users where `email`= '$email'";
$run=mysql_query($query);
$count_occur=0;
while ($row=mysql_fetch_array($run))
{
$count_occur++;
}
if($count_occur!=0) // User already registerd
{
echo "already";
}
else {
mysql_query ("
INSERT INTO users
( name, email,
password, address)
VALUES
(
'".$fullname."',
'".$email."','".$hash_pass."',
'".$address."'
)
") or die (mysql_error());
echo "successful";
}
}
}
?>