-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
66 lines (64 loc) · 2.63 KB
/
Copy pathsignup.php
File metadata and controls
66 lines (64 loc) · 2.63 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
include './components/dbConn.php';
$created = false;
$message = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){
$un = $_POST["username"];
$pass = $_POST["password"];
$cPass = $_POST["confirm-password"];
$sql = "INSERT INTO users VALUE ('$un', '$pass')";
if($pass === $cPass){
if($connection->query($sql) === true){
$message = "User Created Successfully";
$created = true;
// header("location: signup.php");
}
else{
$message = $connection->error;
// header("location: signup.php");
}
}
else{
$message = "Password and Confirm Password does not match";
// header("location: signup.php");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<?php include './components/navbar.php' ?>
<div class="container">
<form method="post">
<div class="form-group" style="margin-top: 15px">
<label for="exampleInputEmail1">Username</label>
<input type="text" name ="username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter Username" style="width: 300px">
</div>
<div class="form-group" style="margin-top: 15px">
<label for="exampleInputPassword1">Password</label>
<input type="password" name="password" class="form-control" id="exampleInputPassword1" placeholder="Password" style="width: 300px">
</div>
<div class="form-group" style="margin-top: 15px">
<label for="exampleInputPassword2">Confirm Password</label>
<input type="password" name="confirm-password" class="form-control" id="exampleInputPassword2" placeholder="Confirm Password" style="width: 300px">
</div>
<button type="submit" class="btn btn-primary" style="margin-top: 15px">Submit</button>
</form>
<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['confirm-password'])){
if($created){
printf('<div class="alert alert-success" role="alert" style="width:300px"> %s </div>', $message);
}
else{
printf('<div class="alert alert-danger" role="alert" style="width:300px"> %s </div>', $message);
}
}
}
?>
</div>
</body>
</html>