Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Coded By Iamcoolz
- // Mentored By Jonny
- // ODBC
- $DB = "KN_Online";
- $User = "knight";
- $Pass = "knight";
- // Function
- function sanitize($input,$length)
- {
- return substr(htmlentities($input, ENT_QUOTES), 0, $length);
- }
- // Check
- if (!$_POST)
- echo '
- <div align = "center">
- <form action = "Register.php" method="post">
- <div align = "center">ID: <input type="text" name="userid" /></div>
- <div align = "center">Password: <input type="text" name="pass1" /></div>
- <div align = "center">Confirm Password: <input type="text" name="pass2" /></div>
- <div align = "center">Security Code: <input type="text" name="charsil" /></div>
- <div align = "center">Confirm Security Code: <input type="text" name="charsil1" /></div>
- <div align = "center">Email: <input type="text" name="email" /></div>
- <div align = "center">Confirm Email: <input type="text" name="email1" /></div>
- <div align = "center"><input type = "submit" value = "Register" /></div>
- </form>
- </div>
- ';
- else
- {
- // Posted Data
- $login = trim (sanitize (@$_POST['userid'], 15));
- $pw = trim (sanitize (@$_POST['pass1'], 15));
- $c_pw = trim (sanitize (@$_POST['pass2'], 15));
- $socNo = trim (sanitize (@$_POST['charsil'], 5));
- $socNo2 = trim (sanitize (@$_POST['charsil1'], 5));
- $email = trim (sanitize (@$_POST['email'], 25));
- $email2 = trim (sanitize (@$_POST['email1'], 25));
- // Error Codes
- if ($pw != $c_pw)
- {
- echo 'Passwords don\'t match.';
- die ();
- }
- if (empty ($login))
- {
- echo 'Fill In Login Field';
- die ();
- }
- if (empty ($pw) ||
- empty ($c_pw))
- {
- echo 'Fill in Password Field';
- die ();
- }
- if (empty ($socNo) ||
- empty ($socNo2))
- {
- echo 'Fill In Security Code Field';
- die ();
- }
- if (empty ($email) ||
- empty ($email2))
- {
- echo 'Fill In Email Field';
- die ();
- }
- if ($email != $email2)
- {
- echo 'Emails don\'t match.';
- die ();
- }
- // Check For Previous Accounts
- $msconnect=odbc_connect ($DB,$User,$Pass);
- $stmt = odbc_prepare ($msconnect, "select count(*) from TB_User where straccountid = ?");
- $msresul=odbc_execute ($stmt, array ($login));
- odbc_fetch_row ($stmt);
- $count = odbc_result ($stmt, 1);
- if ($count > 0)
- {
- echo 'Account Name In Use';
- die ();
- }
- // Check For Previous Email Accounts
- $stmt = odbc_prepare ($msconnect, "select count(*) from TB_User where email = ?");
- $msresul=odbc_execute ($stmt, array ($email));
- odbc_fetch_row ($stmt);
- $count = odbc_result ($stmt, 1);
- if ($count > 0)
- {
- echo 'Email In Use';
- die ();
- }
- //Registration
- $stmt = odbc_prepare($msconnect, "INSERT INTO TB_USER (strACcountID, strPasswd, strSocNo, Email) VALUES (?,?,?,?)");
- $result = odbc_execute($stmt, array($login,$pw,$socno,$email));
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement