SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | //code tạo mã xác nhận bằng md5 | |
3 | include("config.php"); | |
4 | if(isset($_POST["submit"])){ | |
5 | $ho = addslashes($_POST["ho"]); | |
6 | $ten = addslashes($_POST["ten"]); | |
7 | $email = addslashes($_POST["email"]); | |
8 | $username = addslashes($_POST["username"]); | |
9 | $password = md5($_POST["password"]); | |
10 | $confirmpassword = md5($_POST["confirmpassword"]); | |
11 | $day = addslashes($_POST["day"]); | |
12 | $phone = addslashes($_POST["phone"]); | |
13 | $cmnd = addslashes($_POST["cmnd"]); | |
14 | $_POST["capcha"]; | |
15 | if($ho == "" || $ten == "" || $email == "" || $username == "" || $_POST["password"] == "" || $_POST["confirmpassword"] == "" || $day == "" || $phone == "" || $cmnd == ""){ | |
16 | echo "Bạn chưa điền đầy đủ thông tin"; | |
17 | } | |
18 | if($_POST["password"] != $_POST["confirmpassword"]){ | |
19 | echo "Hai mật khẩu bạn nhập không giống nhau"; | |
20 | } | |
21 | if(mysql_num_rows(mysql_query("SELECT username FROM members WHERE username = '$username'"))>0){ | |
22 | echo "Tài khoản này đã có người sử dụng"; | |
23 | } | |
24 | if(mysql_num_rows(mysql_query("SELECT email FROM members WHERE email = '$email'"))>0){ | |
25 | echo "Email đã có người sử dụng"; | |
26 | } | |
27 | if($_SESSION["security_code"] != $_POST["capcha"]){ | |
28 | echo "Bạn đã nhập sai mã xác nhận"; | |
29 | } | |
30 | $creat = mysql_query('INSERT INTO members(ho,ten,email,username,password,day,phone,cmnd) VALUES($ho, $ten, $email, $username, $password, $day, $phone, $cmnd)'); | |
31 | if($creat){ | |
32 | echo "Đăng ký thành công"; | |
33 | }else{ | |
34 | echo "Đăng ký thất bại"; | |
35 | } | |
36 | } | |
37 | ||
38 | $md5_hash = md5(rand(0,999)); | |
39 | $security_code = substr($md5_hash, 15, 7); | |
40 | $_SESSION["security_code"] = $security_code; | |
41 | ?> |