-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsign_up.php
47 lines (46 loc) · 1.37 KB
/
sign_up.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
<?php
if (isset($_POST['username'])&&isset($_POST['password'])){
include "utilizations.php";
$pdo = database_connection();
$username = htmlspecialchars($_POST['username']);
$password = htmlspecialchars($_POST['password']);
$add_user = "INSERT INTO test_login (username, password) VALUES (:username, :password);";
$preparedNamed = $pdo->prepare($add_user);
$preparedNamed->bindValue(":username", $username);
$preparedNamed->bindValue(":password", $password);
try{
$preparedNamed->execute();
echo "<p>Account <b style=\"color:green;\">".$username."</b> has created.</p>";
echo "<p>Click <a href=\"index.php\">here</a> to go back to continue sign-in.</p>";
mkdir_user($username);
}catch(PDOException $e){
echo var_dump($e).'<br><br>';
if (str_contains($e->getMessage(),"Data too long for column 'username'")){
echo "Username is too long!";
}elseif (str_contains($e->getMessage(),'Duplicate entry')){
echo "Account already existed!/Username Used!";
}
echo "<br> Error!";
}
}
?>
<!DOCTYPE>
<html>
<head>
<title>Sign Up SpXFSS</title>
</head>
<body>
<h4>Sign Up Information</h4>
<form action="" method="POST">
Your Username:
<input type="text", name="username"><br>
Setup Your Password:
<input type="text", name="password"><br>
<input type="submit", value="Sign Up">
</form>
<?php
include "inform.php";
copyright();
?>
</body>
</html>