-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
45 lines (38 loc) · 1.06 KB
/
signup.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
<?php
require_once 'header.php'
?>
<!DOCTYPE html>
<html>
<head>
<title>Singup</title>
</head>
<body>
<header>
<h1>Please Sing Up </h1>
</header>
<div >
<form action="signup.php" method="post">
<p>name</p><input type="text" name="name" placeholder="name" required><br>
<p>password</p><input type="password" name="password" placeholder="password" required><br>
<button type="submit" name="signup" class="btn">Sing up</button>
<span></span>
</form>
</div>
</body>
</html>
<?php
if(isset($_POST['signup'])){
$name=$_POST['name'];
$password=$_POST['password'];
$stmt1=mysqli_query($conn,"SELECT * FROM player WHERE name='$name'");
if($stmt1->num_rows == 0){
$stmt2=$conn->prepare("INSERT INTO player(name,password) VALUES (?,?)");
$stmt2->bind_param("ss",$name,$password);
$stmt2->execute();
echo "<script type='text/javascript'>alert('player sign up success!');window.location.href='login.php';</script>";
}else{
echo "<script type='text/javascript'>alert('player name already exist!')</script>";
}
}
require_once 'footer.php'
?>