Advertisement
Guest User

Untitled

a guest
Jun 8th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.12 KB | None | 0 0
  1. <?php
  2. // ODBC
  3. $DB = "KN_Online";
  4. $User = "Knight";
  5. $Pass = "Knight";
  6.  
  7. // Function
  8. function sanitize($input,$length)
  9. {
  10.         return substr(htmlentities($input, ENT_QUOTES), 0, $length);
  11. }
  12.  
  13. // Check
  14. if (sizeof($_POST)  < 7)
  15. {
  16.  
  17. // Buttons, Text.
  18.  
  19. echo '
  20. <div align = "center">
  21. <form action="Register.php" method="post">
  22. <div align = "center">ID: <input type="text" name="userid" /></div>
  23. <div align = "center">Password: <input type="text" name="pass1" /></div>
  24. <div align = "center">Confirm Passowrd: <input type="text" name="pass2" /></div>
  25. <div align = "center">Security Code: <input type="text" name="charsil" /></div>
  26. <div align = "center">Confirm Security Code: <input type="text" name="charsil1" /></div>
  27. <div align = "center">Email: <input type="text" name="email" /></div>
  28. <div align = "center">Confirm Email: <input type="text" name="email1" /></div>
  29. <div align = "center"><input type = "submit" value = "Register" /></div>
  30. </form>
  31. </div>
  32. ';
  33. }
  34. else
  35. {
  36.  
  37.  
  38. // Posted Data
  39. $login = sanitize($_POST['userid'],5);
  40.             $pw = sanitize($_POST['pass1'],5);
  41.             $c_pw =sanitize($_POST['pass2'],5);
  42.             $socNo = sanitize($_POST['charsil'],4);
  43.             $socNo2 = sanitize($_POST['charsil1'],4);
  44.             $email = sanitize($_POST['email'],25);
  45.             $email2 = sanitize($_POST['email1'],25);
  46.  
  47.  
  48.  
  49. // Error Codes
  50. if ($pw == $c_pw) {
  51. echo 'Password Confirmed';
  52. die();
  53. }
  54.  
  55. if (empty($login)) {
  56. echo 'Fill In Login Field';
  57. die();
  58. }
  59.  
  60. if (empty($pw) || empty($c_pw)) {
  61. echo 'Fill in Password Field';
  62. die();
  63. }
  64.  
  65. if (empty($socNo) || empty($socNo2)) {
  66. echo 'Fill In Security Code Field';
  67. die();
  68. }
  69.  
  70. if (empty($email) || empty($email2)) {
  71. echo 'Fill In Email Field';
  72. die();
  73. }
  74.  
  75. // Check For Previous Accounts
  76. $msconnect=odbc_connect($DB,$User,$Pass);
  77. $stmt = odbc_prepare($msconnect, " select count  from table where straccountid = ?");
  78.  if count > 0 deny {
  79.  echo 'Account Name In Use'
  80.  die ();
  81.  }
  82.  
  83.  
  84. //Registration
  85. $stmt = odbc_prepare($msconnect, "INSERT INTO TB_USER (strACcountID, strPasswd, strSocNo, Email) VALUES (?,?,?,?)");
  86.     $result = odbc_execute($stmt, array($login,$pw,$socno,$email));
  87.  
  88. }
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement