login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Problemen met MySQL met leden systeem

Offline Jamiel - 01/06/2008 14:21 (laatste wijziging 01/06/2008 16:44)
Avatar van JamielNieuw lid Ik krijg als ik op submit klik krijg ik deze foutmelding: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/arens/domains/arens.gethost.nl/public_html/register.php on line 136

dit is mijn script:
  1. <?
  2. if($_SESSION['login'] == "true"){
  3. print " You have allready an account.";//because your logged in stupid
  4. }
  5.  
  6. include('connect.inc.php');
  7. if(!isset($_REQUEST['submit'])){
  8. ?>
  9. <form method=post acion=""<? $_SERVER['PHP_SELF'] ?>"">
  10. <table>
  11. <tr>
  12. <td>
  13. <font face=verdana size=1>Username:
  14. </td>
  15. <td>
  16. <input type="text" name="name" maxlength="15">
  17. </td>
  18. </tr>
  19. <tr>
  20. <td>
  21. <font face=verdana size=1>Password:
  22. </td>
  23. <td>
  24. <input type="password" name="pass1">
  25. </td>
  26. </tr>
  27. <tr>
  28. <td>
  29. <font face=verdana size=1>Confirm:
  30. </td>
  31. <td>
  32. <input type="password" name="pass2">
  33. </td>
  34. </tr>
  35. <tr>
  36. <td>
  37. <input type="submit" value=submit name="submit">
  38. </td>
  39. <td>
  40. <input type="reset">
  41. </td>
  42. </tr>
  43. </table>
  44. </form>
  45. <?php
  46. }else{
  47. //request everything
  48. $dead = "false";//We make 'dead' if some fields are not filled in don't check for pass and name in db.
  49. $message = "<font face=verdana size=1>Pleas fill in all fields correctly:<br>";
  50. $username = $_POST['name'];
  51. $pass1 = $_POST['pass1'];
  52. $pass2 = $_POST['pass2'];
  53. $ip = $_SERVER['REMOTE_ADDR'];
  54. $status = "1";//1 member, 2,co-admin 3, admin
  55. //begin search for errors
  56. if(strlen($username) <= 1 or strlen($username) >=15){
  57. $dead = "true";
  58. $message .= "Username (2-14)<br>";
  59. }
  60. if(strlen($pass1) < 6 or strlen($pass1) > 20 or $pass1 !== $pass2) {
  61. $dead = "true";
  62. $message .= "Password (6-20) or passwords does not match";
  63. }
  64. if($dead = "false"){
  65. $username = strtolower(trim(strip_tags($username)));
  66. $pass1 = trim($pass1);
  67. $pass1 = md5($pass1);
  68. $query = mysql_query("SELECT * FROM members WHERE username ='$username'");
  69. $aantalrijen = mysql_num_rows($query);
  70. if($aantalrijen == 1){
  71. print "<font face=verdana size=1>Sorry, your username exists allready.";
  72. }
  73. else{
  74. $query1 = "INSERT INTO members(username, password, ip, status) VALUES ('$username','$pass1', '$ip','$status')";
  75. if(mysql_query($query1)){
  76. print "<font face=verdana size=1>Well donne your now a member of the RTD group.<br><a href=login.php>Login</a>";
  77. }
  78. }
  79.  
  80. }
  81. elseif($dead == "true"){
  82. print $message;
  83. }
  84. }
  85. ?>

wat moet ik doen? 

Psycho schreef:
Als eerste moet je leren de UBB tags te gebruiken...

8 antwoorden

Gesponsorde links
Offline Jamiel - 01/06/2008 14:24 (laatste wijziging 01/06/2008 14:25)
Avatar van Jamiel Nieuw lid
  1. <?
  2. if($_SESSION['login'] == "true"){
  3. print " You have allready an account.";//because your logged in stupid
  4. }
  5.  
  6. include('connect.inc.php');
  7. if(!isset($_REQUEST['submit'])){
  8. ?>
  9. <form method=post acion=""<? $_SERVER['PHP_SELF'] ?>"">
  10. <table>
  11. <tr>
  12. <td>
  13. <font face=verdana size=1>Username:
  14. </td>
  15. <td>
  16. <input type="text" name="name" maxlength="15">
  17. </td>
  18. </tr>
  19. <tr>
  20. <td>
  21. <font face=verdana size=1>Password:
  22. </td>
  23. <td>
  24. <input type="password" name="pass1">
  25. </td>
  26. </tr>
  27. <tr>
  28. <td>
  29. <font face=verdana size=1>Confirm:
  30. </td>
  31. <td>
  32. <input type="password" name="pass2">
  33. </td>
  34. </tr>
  35. <tr>
  36. <td>
  37. <input type="submit" value=submit name="submit">
  38. </td>
  39. <td>
  40. <input type="reset">
  41. </td>
  42. </tr>
  43. </table>
  44. </form>
  45. <?php
  46. }else{
  47. //request everything
  48. $dead = "false";//We make 'dead' if some fields are not filled in don't check for pass and name in db.
  49. $message = "<font face=verdana size=1>Pleas fill in all fields correctly:<br>";
  50. $username = $_POST['name'];
  51. $pass1 = $_POST['pass1'];
  52. $pass2 = $_POST['pass2'];
  53. $ip = $_SERVER['REMOTE_ADDR'];
  54. $status = "1";//1 member, 2,co-admin 3, admin
  55. //begin search for errors
  56. if(strlen($username) <= 1 or strlen($username) >=15){
  57. $dead = "true";
  58. $message .= "Username (2-14)<br>";
  59. }
  60. if(strlen($pass1) < 6 or strlen($pass1) > 20 or $pass1 !== $pass2) {
  61. $dead = "true";
  62. $message .= "Password (6-20) or passwords does not match";
  63. }
  64. if($dead = "false"){
  65. $username = strtolower(trim(strip_tags($username)));
  66. $pass1 = trim($pass1);
  67. $pass1 = md5($pass1);
  68. $query = mysql_query("SELECT * FROM members WHERE username ='$username'");
  69. $aantalrijen = mysql_num_rows($query);
  70. if($aantalrijen == 1){
  71. print "<font face=verdana size=1>Sorry, your username exists allready.";
  72. }
  73. else{
  74. $query1 = "INSERT INTO members(username, password, ip, status) VALUES ('$username','$pass1', '$ip','$status')";
  75. if(mysql_query($query1)){
  76. print "<font face=verdana size=1>Well donne your now a member of the RTD group.<br><a href=login.php>Login</a>";
  77. }
  78. }
  79.  
  80. }
  81. elseif($dead == "true"){
  82. print $message;
  83. }
  84. }
  85. ?>
Offline Jamiel - 01/06/2008 14:31
Avatar van Jamiel Nieuw lid hoe verander ik dat?
Offline Jamiel - 01/06/2008 14:38
Avatar van Jamiel Nieuw lid hij doet het nog steeds niet
Offline Jamiel - 01/06/2008 14:50
Avatar van Jamiel Nieuw lid waar dan precies?
Offline Jamiel - 01/06/2008 14:52
Avatar van Jamiel Nieuw lid waar achter me query
Offline Jamiel - 01/06/2008 15:22
Avatar van Jamiel Nieuw lid nu krijg ik een tstring error
Offline Ibrahim - 02/06/2008 11:06
Avatar van Ibrahim PHP expert @Sandernerd, de error is een T_STRING error, dat betekent dat hij ergens een quote ofzo niet heeft afgesloten.

@Jamiel: het zou handig zijn als je je code op plaatscode zet en per verandering het even update zodat de rest het proces mee kunnen volgen.
Offline Gerard - 09/06/2008 01:45
Avatar van Gerard Ouwe rakker Probeer het anders eens met dit script. Of neem er anders een voorbeeldje aan ;)
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2025 Sitemasters.be - Regels - Laadtijd: 0.416s