Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. include 'conn.php';
  3.  
  4. if (mysqli_connect_errno()) {
  5. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  6. }
  7.  
  8. ?>
  9. <!doctype html>
  10. <html>
  11. <head>
  12. <title>Project Cinccino - Registration Submit</title>
  13. </head>
  14. <body>
  15. <?php
  16. if(!empty($_POST["username"]) && strlen($_POST["username"]<15)){
  17. if(ctype_alnum($_POST["username"])===true){
  18. $username=mysqli_real_escape_string($con,$_POST["username"]);
  19. if(!empty($_POST["password"]) && $_POST["password"] === $_POST["passwordconf"]){
  20. $password=mysqli_real_escape_string($con,$_POST["password"]);
  21. $password=password_hash($password,PASSWORD_DEFAULT);
  22. $ipaddress=$_SERVER['REMOTE_ADDR'];
  23. $check=mysqli_query($con,"select * FROM userinfo WHERE username='$username' and ipaddress='$ipaddress'");
  24. $checkdup=mysqli_num_rows($check);
  25. if($checkdup>0){die();}else{
  26. $sql="INSERT INTO userinfo (username, password, ipaddress)
  27. VALUES ('$username', '$password', '$ipaddress')";
  28.  
  29.  
  30. echo "You have been registered successfully!";
  31. }
  32. }else{echo "ERROR: Your username needs to be 15 characters or less and it cannot be left blank!";}
  33. }else{echo "ERROR: Your username needs to be alphanumeric!";}
  34. }else{echo "ERROR: Your password doesn't match the confirmation password and it cannot be left blank!";}
  35. ?>
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement