-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoSignUp.php
44 lines (37 loc) · 1.19 KB
/
doSignUp.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
<?php
require_once ("pdo-connect.php");
$account=$_POST["account"];
$name=$_POST["name"];
$email=$_POST["email"];
$mobile=$_POST["mobile"];
$password=$_POST["password"];
$RePassword=$_POST["RePassword"];
$valid=1;
if($password!==$RePassword){
echo '<div class="alert alert-warning" role="alert">
密碼不一致</div>';
exit();
}
//$crPassword=md5($password);
//echo "$crPassword<br>";
$sqlCheck="SELECT * FROM users WHERE account=? ";
$stmtCheck=$db_host->prepare($sqlCheck);
$stmtCheck->execute([$account]);
$emailExist=$stmtCheck->rowCount();
//echo $userExist;
if($emailExist>0){
echo '<div class="alert alert-warning" role="alert">
已有相同信箱進行註冊!</div>';
exit();
}
$now=date("Y-m-d H:i:s");
$sql="INSERT INTO users( account , name , email, mobile , password , valid , created_at)VALUES(?, ?, ?, ?, ?, ?, ?)";
$stmt=$db_host->prepare($sql);
try{
$stmt->execute([$account, $name, $email, $mobile, $password, $valid, $now]);
echo "<script> alert('註 冊 成 功'); window.location.href='user.php?id=$id'</script>";
header("location: sign-in.php");
}catch(PDOException $e){
echo $e->getMessage();
}
?>