Advertisement
Guest User

dnh

a guest
Mar 19th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <?php
  2. //code tạo mã xác nhận bằng md5
  3. include("config.php");
  4. $md5_hash = md5(rand(0,999));
  5. $security_code = substr($md5_hash, 15, 7);
  6. $_SESSION["security_code"] = $security_code;
  7. if(isset($_POST["submit"])){
  8. $ho = addslashes($_POST["ho"]);
  9. $ten = addslashes($_POST["ten"]);
  10. $email = addslashes($_POST["email"]);
  11. $username = addslashes($_POST["username"]);
  12. $password = md5($_POST["password"]);
  13. $confirmpassword = md5($_POST["confirmpassword"]);
  14. $day = addslashes($_POST["day"]);
  15. $phone = addslashes($_POST["phone"]);
  16. $cmnd = addslashes($_POST["cmnd"]);
  17. $_POST["capcha"];
  18. if($ho == "" || $ten == "" || $email == "" || $username == "" || $_POST["password"] == "" || $_POST["confirmpassword"] == "" || $day == "" || $phone == "" || $cmnd == ""){
  19. echo "Bạn chưa điền đầy đủ thông tin";
  20. }
  21. if($_POST["password"] != $_POST["confirmpassword"]){
  22. echo "Hai mật khẩu bạn nhập không giống nhau";
  23. }
  24. if(mysql_num_rows(mysql_query("SELECT username FROM members WHERE username = '$username'"))>0){
  25. echo "Tài khoản này đã có người sử dụng";
  26. }
  27. if(mysql_num_rows(mysql_query("SELECT email FROM members WHERE email = '$email'"))>0){
  28. echo "Email đã có người sử dụng";
  29. }
  30. if($_SESSION["security_code"] != $_POST["capcha"]){
  31. echo "Bạn đã nhập sai mã xác nhận";
  32. }
  33. $creat = mysql_query('INSERT INTO members(ho,ten,email,username,password,day,phone,cmnd) VALUES($ho, $ten, $email, $username, $password, $day, $phone, $cmnd)');
  34. if($creat){
  35. echo "Đăng ký thành công";
  36. }else{
  37. echo "Đăng ký thất bại";
  38. }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement