login  Naam:   Wachtwoord: 
Registreer je!
 Forum

mail | Pagina 2

32 antwoorden

Gesponsorde links
Offline MothZone - 23/10/2005 23:02 (laatste wijziging 23/10/2005 23:05)
Avatar van MothZone PHP ver gevorderde Ok, heb ff je code is helemaal bekeken en denk dat ik de fout heb gevonden.

Je deed dit:
<form />
<input>
</form>
terwijl het zo is:
<form>
<input>
</form>

Heb ondertussen de rest van de code wat overzichtelijker gemaakt, en ben tot de conclusie gekomen dat 3 POST-variabelen niet meegestuurd worden.
Er staat in de commentaar bij welke.

  1. <?php
  2. include "include/config.php";
  3. include "include/functions.php";
  4. $ip = $_SERVER['REMOTE_ADDR'];
  5. $date = date("d-m-Y H:i:s");
  6. ?>
  7. <form action="register.php" method="post" name="register">
  8. Username:<br />
  9. <input type="text" name="username" maxlength="50" /><br />
  10. Password:<br />
  11. <input type="password" name="pass" maxlength="200" /><br />
  12. Password [confirm]:<br />
  13. <input type="password" name="cpass" maxlength="200" /><br />
  14. Email:<br />
  15. <input type="text" name="mail" maxlength="250" /><br />
  16. Email [confirm]:<br />
  17. <input type="text" name="cmail" maxlength="250" /><br />
  18. Your IP:<br />
  19. <input type="text" name="your_ip" value="<? print "$ip" ?>" disabled /><br />
  20. Date/time:<br />
  21. <input type="text" name="date/time" value="<? print "$date" ?>" disabled /><br />
  22. <input type="submit" name="submit" value="Submit!" /><br />
  23. </form>
  24. <?php
  25. if(isset($_POST['submit']))
  26. {
  27. $username = $_POST['username'];
  28. $pass = $_POST['pass'];
  29. $cpass = $_POST['cpass'];
  30. $mail = $_POST['mail'];
  31. $cmail = $_POST['cmail'];
  32.  
  33. function check_mail($in)
  34. {
  35. $patroon = "/^([a-z0-9_-]+\.)*[a-z0-9_-]+@([a-z0-9_-]{2,}\.)+([a-z0-9_-]{2,})$/i";
  36. return preg_match($patroon, $in);
  37. }
  38.  
  39. $query = mysql_query("SELECT * FROM users") or die(mysql_error());
  40. $check = mysql_num_rows($query);
  41.  
  42. $checkname = mysql_query("SELECT username FROM users WHERE username = '".$username."'") or die (mysql_error());
  43. $checkname = mysql_num_rows($checkname);
  44.  
  45. $checkemail = mysql_query("SELECT mail FROM users WHERE mail = '".$mail."'") or die (mysql_error());
  46. $checkemail = mysql_num_rows($checkemail);
  47.  
  48. $checkip = mysql_query("SELECT ip FROM users WHERE ip = '".$ip."'") or die (mysql_error());
  49. $checkip = mysql_num_rows($checkip);
  50.  
  51.  
  52. if(empty($username))
  53. {
  54. echo "You must fill in an username";
  55. }
  56. elseif(empty($pass))
  57. {
  58. echo "You have to fill in a password";
  59. }
  60. elseif(empty($cpass))
  61. {
  62. echo "You have to confirm your password";
  63. }
  64. elseif(!check_mail($_POST['mail']))
  65. {
  66. echo "You have to fill in an email address";
  67. }
  68. elseif(!check_mail($_POST['cmail']))
  69. {
  70. echo "You have to confirm your email address";
  71. }
  72. elseif($pass != $cpass)
  73. {
  74. echo "Your passwords must be the same";
  75. }
  76. elseif($username == $pass)
  77. {
  78. echo "For saftey can your username and password not be the same";
  79. }
  80. elseif($mail != $cmail)
  81. {
  82. echo "You have to fill in your email address twice";
  83. }
  84. elseif($checkemail > 0)
  85. {
  86. echo "That email address has already been used";
  87. }
  88. elseif($checkname > 0)
  89. {
  90. echo "That username has already been taken";
  91. }
  92. elseif($checkip > 0)
  93. {
  94. echo "Only 1 account per ip is allowed";
  95. }
  96. else
  97. {
  98. $pass = md5($pass);
  99.  
  100. if($check == 0)
  101. {
  102. INSERT INTO `users`
  103. (
  104. id,
  105. username,
  106. pass,
  107. ip,
  108. mail,
  109. activation,
  110. date,
  111. subtitle,
  112. status
  113. )
  114. VALUES
  115. (
  116. '',
  117. '".$username."',
  118. '".$pass."',
  119. '".$ip."',
  120. '".$mail."',
  121. '".$key."',
  122. NOW(),
  123. 'Webmaster!',
  124. 'webmaster'
  125. )
  126. ") or die(mysql_error());
  127.  
  128. echo "There is an email with activation on the way!";
  129. }
  130. else
  131. {
  132. INSERT INTO `users`
  133. (
  134. id,
  135. username,
  136. pass,
  137. ip,
  138. mail,
  139. activation,
  140. date,
  141. subtitle,
  142. status
  143. )
  144. VALUES
  145. (
  146. '',
  147. '".$username."',
  148. '".$pass."',
  149. '".$ip."',
  150. '".$mail."',
  151. '".$key."',
  152. NOW(),
  153. 'Lid!',
  154. 'lid'
  155. )
  156. ") or die(mysql_error());
  157.  
  158. echo "There is an email with activation on the way!";
  159.  
  160. $username = $_POST['username'];
  161. $mail = $_POST['mail'];
  162.  
  163. $webmaster = $_POST['webmaster']; // Bestaat niet!!!
  164. $webmaster_mail = $_POST['webmaster_mail']; // Bestaat niet!!!
  165.  
  166. $subject = $_POST['Complete registration']; // Bestaat niet!!!
  167.  
  168. $headers = "From: ".$webmaster." <".$webmaster_mail.">\r\n";
  169. $headers .= "MIME-Version: 1.0\r\n";
  170. $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  171.  
  172. $message = "You have registered on ".$url.". To confirm your registration, click the link below
  173. ".$url."leden/activeer.php?email=".$mail."&key=".$key."
  174. If you haven't registered, just ignore this email, the account will be deleted in 48 hours.
  175. ";
  176.  
  177. mail($mail, $subject, $message, $headers);
  178. }
  179. }
  180. }
  181. ?>


Dus ik vermoed dat het de html-code was ipv de php-code.

Trouwens, dat zwart kleurtje op RickyB zn naam, betekend dat dat hij verbannen is?

Murfy edit: inderdaad, goed gezien 
Offline Ultimatum - 23/10/2005 23:57 (laatste wijziging 24/10/2005 03:24)
Avatar van Ultimatum PHP expert $webmaster, $webmaster_mail zijn gedefineerd in include/config.php 
enne subject die maak ik daar toch aan of zie ik het nou verkeerd (zoals eerder vermeld, ben ik geen pro )

iig bedankt, zal ff kijken of de code het doet 

edit: nope nog steeds inbox (+ ongewenste post) leeg
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.249s