Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.60 KB | None | 0 0
  1. <?php
  2. // Coded By Iamcoolz
  3. // Mentored By Jonny
  4.  
  5.  
  6. // ODBC
  7. $DB = "KN_Online";
  8. $User = "knight";
  9. $Pass = "knight";
  10.  
  11. // Function
  12. function sanitize($input,$length)
  13. {
  14.         return substr(htmlentities($input, ENT_QUOTES), 0, $length);
  15. }
  16.  
  17. // Check
  18. if (!$_POST)
  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 Password: <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. else
  34. {
  35.         // Posted Data
  36.         $login = trim (sanitize (@$_POST['userid'], 15));
  37.     $pw = trim (sanitize (@$_POST['pass1'], 15));
  38.     $c_pw = trim (sanitize (@$_POST['pass2'], 15));
  39.     $socNo = trim (sanitize (@$_POST['charsil'], 5));
  40.     $socNo2 = trim (sanitize (@$_POST['charsil1'], 5));
  41.     $email = trim (sanitize (@$_POST['email'], 25));
  42.     $email2 = trim (sanitize (@$_POST['email1'], 25));
  43.  
  44.         // Error Codes
  45.         if ($pw != $c_pw)
  46.         {
  47.                 echo 'Passwords don\'t match.';
  48.                 die ();
  49.         }
  50.        
  51.         if (empty ($login))
  52.         {
  53.                 echo 'Fill In Login Field';
  54.                 die ();
  55.         }
  56.        
  57.         if (empty ($pw) ||
  58.             empty ($c_pw))
  59.         {
  60.                 echo 'Fill in Password Field';
  61.                 die ();
  62.         }
  63.        
  64.         if (empty ($socNo) ||
  65.             empty ($socNo2))
  66.         {
  67.                 echo 'Fill In Security Code Field';
  68.                 die ();
  69.         }
  70.        
  71.         if (empty ($email) ||
  72.             empty ($email2))
  73.         {
  74.                 echo 'Fill In Email Field';
  75.                 die ();
  76.         }
  77.    
  78.     if ($email != $email2)
  79.     {
  80.         echo 'Emails don\'t match.';
  81.         die ();
  82.     }
  83.  
  84.         // Check For Previous Accounts
  85.         $msconnect=odbc_connect ($DB,$User,$Pass);
  86.         $stmt = odbc_prepare ($msconnect, "select count(*) from TB_User where straccountid = ?");
  87.         $msresul=odbc_execute ($stmt, array ($login));
  88.         odbc_fetch_row ($stmt);
  89.         $count = odbc_result ($stmt, 1);
  90.        
  91.         if ($count > 0)
  92.         {
  93.                 echo 'Account Name In Use';
  94.                 die ();
  95.         }
  96.        
  97.         // Check For Previous Email Accounts
  98.         $stmt = odbc_prepare ($msconnect, "select count(*) from TB_User where email = ?");
  99.         $msresul=odbc_execute ($stmt, array ($email));
  100.         odbc_fetch_row ($stmt);
  101.         $count = odbc_result ($stmt, 1);
  102.        
  103.         if ($count > 0)
  104.         {
  105.                 echo 'Email In Use';
  106.                 die ();
  107.         }
  108.        
  109.         //Registration
  110.         $stmt = odbc_prepare($msconnect, "INSERT INTO TB_USER (strACcountID, strPasswd, strSocNo, Email) VALUES (?,?,?,?)");
  111.         $result = odbc_execute($stmt, array($login,$pw,$socno,$email));
  112. }
  113. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement