Guest User

Untitled

a guest
Jul 7th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. <form method="post" action="" enctype="multipart/form-data" onSubmit="registeruser()">
  2. <div>
  3. Username <span class="required">*</span><br/> <input class="registerinputbox" type="text" name="username" size="20"/><br/>
  4. Password <span class="required">*</span><br/> <input class="registerinputbox" type="password" name="password" size="20"/><br/>
  5. E-Mail <span class="required">*</span><br/> <input class="registerinputbox" type="text" name="email" size="20"/><br/>
  6. <input class="registerbutton" type="submit" name="registerbutton" value="Register"/> <span class="required">*</span> = required
  7. </div>
  8. </form>
  9.  
  10.  
  11. ----------------------------------------------------------------------------
  12.  
  13. function registeruser() {
  14. if (document.getElementById("content").value == "") {
  15. return false;
  16. }
  17.  
  18. if (window.XMLHttpRequest) {
  19. var xhr = new XMLHttpRequest();
  20. }
  21. else {
  22. var xhr = new ActiveXObject("Microsoft.XMLHTTP");
  23. }
  24.  
  25. xhr.onreadystatechange = function() {
  26. if (xhr.readyState == 4) {
  27. var posts = xhr.responseText;
  28. document.getElementById("content").innerHTML = posts;
  29. }
  30. else {
  31. document.getElementById("content").innerHTML ='<img src="ajax-loader.gif"/>';
  32. }
  33. }
  34.  
  35. xhr.open("GET", "registeruser.php");
  36. xhr.send(null);
  37.  
  38. document.getElementById("content").style.display='block';
  39. }
  40.  
  41. ----------------------------------------------------------------------
  42.  
  43. <?php
  44.  
  45. $conn = blah;
  46.  
  47. $username = mysqli_real_escape_string($conn,strip_tags($_POST['username']));
  48. $password = mysqli_real_escape_string($conn,strip_tags($_POST['password']));
  49. $email = mysqli_real_escape_string($conn,strip_tags($_POST['email']));
  50.  
  51. if (strlen($username) > 15) {
  52. echo "The username you are trying to register is over the max of 15 characters, please go <a href='javascript:register()'>back</a> and try agian." ;
  53. die;
  54. }
  55.  
  56. if (strlen($password) > 15) {
  57. echo "The password you are trying to register is over the max of 15 characters, please go <a href='javascript:register()'>back</a> and try agian." ;
  58. die;
  59. }
  60.  
  61. if (strlen($email) > 35) {
  62. echo "The email you are trying to register is over the max of 35 characters, please go <a href='javascript:register()'>back</a> and try agian." ;
  63. die;
  64. }
  65.  
  66. $sp_checkuserdb = "CALL checkuserdb('$username','$email')";
  67. $rs_checkuserdb = mysqli_query($conn, $sp_checkuserdb);
  68.  
  69. $checkuserdb_result = mysqli_num_rows($rs_checkuserdb);
  70. if ($checkuserdb_result >= 1) {
  71. echo $username;
  72. echo "The username or email you are trying to register is already in use, please go <a href='javascript:register()'>back</a> and try agian." ;
  73. die;
  74. }
  75.  
  76. $conn = blah;
  77.  
  78. $sp_registeruser = "CALL registeruser('$username','$password','$email')";
  79. $run_registeruser = mysqli_query($conn, $sp_registeruser);
  80.  
  81. echo "Thanks for registering, you may now login and begin posting!" ;
  82.  
  83. ?>
Add Comment
Please, Sign In to add comment