943,021 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 48
  • PHP RSS
Sep 7th, 2010
0

Help with my Register Script

Expand Post »
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. require('./configs/reg_conf.php');
  3. function doesUsernameExist($name){
  4. $exit = FALSE;
  5. $result = @mssql_query("SELECT * FROM ACCOUNT_TBL WHERE account='$name'");
  6. if (mssql_num_rows($result) != 0){
  7. $exit = TRUE;
  8. }
  9. return $exit;
  10. }
  11.  
  12. if(isset($_POST['submit'])){
  13. $user = preg_replace ("[^A-Za-z0-9]", "", $_POST['username']);
  14. $pass = preg_replace ("[^A-Za-z0-9]", "", $_POST['password']);
  15. if($_POST['username'] == ""){
  16. echo '<font color="red">Enter a user.</font><br /><br />';
  17. }
  18. else if($_POST['password'] == ""){
  19. echo '<font color="red">Enter a password.</font><br /><br />';
  20. }
  21. else if ((strlen($_POST['username']) > 16) || (strlen($_POST['username']) < 3)){
  22. echo '<font color="red">The user should be 3 to 16 characters.</font><br /><br />';
  23. }
  24. else if ((strlen($_POST['password']) > 16) || (strlen($_POST['password']) < 3)){
  25. echo '<font color="red">The password should be 3 to 16 characters.</font><br /><br />';
  26. }
  27. else if($_POST['username'] != $user){
  28. echo '<font color="red">User with invalid characters.</font><br /><br />';
  29. }
  30. else if($_POST['password'] != $pass){
  31. echo '<font color="red">Password with invalid characters.</font><br /><br />';
  32. }
  33. else {
  34. $pass = md5('serus' . $pass);
  35. if(!doesUsernameExist($user)){
  36. $stmt = mssql_init('createaccount', $link);
  37. mssql_bind($stmt, '@account', $user, SQLVARCHAR, false, false, 15);
  38. mssql_bind($stmt, '@password', $pass, SQLVARCHAR, false, false, 36);
  39.  
  40. mssql_execute($stmt) or die ("Something is wrong on the execution");
  41. mssql_free_statement($stmt);
  42. echo '<font color="blue">Register Successfull.</font><br /><br />';
  43. }
  44. else {
  45. echo '<font color="red">User already Exist.</font><br /><br />';
  46. }
  47. }
  48. mssql_close();
  49. }
  50.  
  51. echo '<form action="register.php" method="post">';
  52. echo 'Username: <input type="text" name="username" /><br />';
  53. echo 'Password: <input type="password" name="password" /><br />';
  54. echo '<input type="submit" name="submit" value="Register" />';
  55. echo '</form>';
  56.  
  57. ?>
Last edited by Ezzaral; Sep 7th, 2010 at 3:17 pm. Reason: Added code tags. Please use them to format any code that you post.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
amras123 is offline Offline
13 posts
since Jan 2010
Sep 7th, 2010
0
Re: Help with my Register Script
what's the problem?
Reputation Points: 10
Solved Threads: 7
Light Poster
farhan386 is offline Offline
44 posts
since Jul 2008
Sep 8th, 2010
0
Re: Help with my Register Script
If you will post the dependent config files along with the database structure sql
we will be able to find out exactly the issues. And try to arrive at a solution.
Reputation Points: 16
Solved Threads: 14
Junior Poster
sourcebits is offline Offline
102 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: search substring from strings
Next Thread in PHP Forum Timeline: PHP & MySQL BLOB Download Issue





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC