-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
102 lines (77 loc) · 3.68 KB
/
signup.php
File metadata and controls
102 lines (77 loc) · 3.68 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
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
<?php
session_start();
$showerror=false;
$exist = false;
include './connects/config.php';
include 'function.php';
if(isset($_POST['signup'])){
$fname = $_POST["fname"];
$email = $_POST["email"];
$pass = $_POST["password"];
$token = date("Ymdhis").rand(10,100);
// Trim , Escape and Validate
$fname = sec($fname);
$email = sec($email);
$pass = sec($pass);
$token = sec($token);
$mysql = "SELECT * FROM user where email='$email'";
$res = mysqli_query($conn, $mysql);
$count =mysqli_num_rows($res);
if($count==0){
// if yes code goes here
//insert into DB
$iq="INSERT INTO user (email, pass, fname, token) VALUES('$email', '$pass', '$fname',$token)";
if($iqd = mysqli_query($conn, $iq))
{ $_SESSION["name"]= $fname;
$_SESSION["email"] = $email;
header('Location: dashboard.php');
}else{
echo "insert ERROR";
}
}else{
// else code goes here
$showerror = " Email already exist. Please login";
}
}else{
// NOTHING
}
?>
<!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">
<title>Signup - <?php echo $siteTitle ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
</head>
<body style="background-color: #202124;">
<div class="container" >
<div class="vh-100 row align-items-center d-flex justify-content-center">
<div class="col"></div>
<div class="col">
<img src="https://techsanjal.com/wp-content/uploads/2023/01/Tech-Sanjal-Logo.png" class="img" style="height: auto; width: 100%;" >
<form method="post" action='<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>'>
<div class="text-danger">
<?php echo $showerror; ?>
</div>
<label for="signupName" class="form-lebel text-light">Name: </label>
<input type="text" class="form-control" id="signupName" name="fname">
<label for="loginEmail" class="form-lebel text-light">Email: </label>
<input type="email" class="form-control" id="loginEmail" name="email">
<label for="loginPassword" class="form-lebel text-light">Password: </label>
<input type="password" class="form-control" id="loginPassword" name="password">
<br>
<button class="btn btn-primary" name="signup">Create Account</button>
</form>
<hr>
<div class="text-light link-light center">
<a href="login.php">Login</a>
<a href="#">Reset PASSWORD</a>
</div>
</div>
<div class="col"></div>
</div>
</div>
</body>
</html>