Advertisement
Guest User

Untitled

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