944,030 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 637
  • PHP RSS
Nov 6th, 2009
-3

Please Help Me Fix My PHP Register Form

Expand Post »
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. if(isset($_POST['register']))
  3. {
  4. $username = $_POST["username"];
  5. $password = $_POST["password"];
  6. $email = $_POST["email"];
  7. $conf_pass = $_POST["confirm"];
  8. $error = false;
  9.  
  10. $connect = mysql_connect("localhost", "stickmi1_data", "electricCompany");
  11. $database = mysql_select_db("account", $connect);
  12.  
  13. $usernameCheck = mysql_query("SELECT username FROM users WHERE username = '$username'");
  14.  
  15. // Registration Form Validation Script
  16.  
  17. if(!$username || !$password || !$email || !$conf_pass)
  18. {
  19. $error = true;
  20. $errorMessage = "Please fill in any missing fields before continuing!";
  21. }
  22. else if($password != $conf_pass);
  23. {
  24. $error = true;
  25. $errorMessage = "Your password and confirmation password don't match!";
  26. }
  27. if($usernameCheck > 0)
  28. {
  29. $error = true;
  30. $errorMessage = "The requested username is already in use, try another!";
  31. }
  32. if($error == false)
  33. {
  34. $password = md5($password);
  35. mysql_query("INSERT INTO users(username, password, email) VALUES($username, $password, $email)",$connect);
  36. }
  37. }
  38. ?>
  39. <form name="register_form" method="post">
  40. <table>
  41. <tr>
  42. <td>Username: </td>
  43. <td><input type="text" name="username" /></td>
  44. </tr>
  45. <tr>
  46. <td>Password: </td>
  47. <td><input type="password" name="password" /></td>
  48. </tr>
  49. <tr>
  50. <td>Confirm Pass: </td>
  51. <td><input type="password" name="conf_pass" /></td>
  52. </tr>
  53. <tr>
  54. <td>Email: </td>
  55. <td><input type="text" name="email" /></td>
  56. </tr>
  57. <tr>
  58. <td><input type="submit" name="register" value="Register" /></td>
  59. </tr>
  60. </table>
  61. </form>
Last edited by Ezzaral; Nov 6th, 2009 at 4:54 pm. Reason: Added code tags. Please use them to format any code that you post.
Similar Threads
Reputation Points: 10
Solved Threads: 6
Light Poster
Chosen13 is offline Offline
38 posts
since Nov 2009
Nov 6th, 2009
0
Re: Please Help Me Fix My PHP Register Form
1. Please use [code][/code] tags to post your code.
2. Tell us what the problem is, I for one would not want to read your code and then guess at the problem.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 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: preg_match validation
Next Thread in PHP Forum Timeline: a Function that is not working...





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


Follow us on Twitter


© 2011 DaniWeb® LLC