login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Contact formulier (Opgelost)

Offline Darklevi - 09/02/2010 16:21 (laatste wijziging 09/02/2010 17:00)
Avatar van DarkleviLid Beste Sm-ers,

Ik ben pas net bezig, en heb een paar problemen

Hij verzend alleen het onderwerp, naam enz niet. Heb nieuwe dingen toevoegt zoals merk die word wel verstuurd maar bericht er de rest niet

  1. <?php
  2. // Your e-mail adress:
  3. $mailto = "info@topautoparts.nl";
  4.  
  5. # Maximum size of attachment in bytes:
  6. $max_attach_size = 500000;
  7.  
  8. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  9. <html>
  10. <head>
  11. <title>Contact</title>
  12. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  13.  
  14. </head>
  15. <body><?php
  16. /*if (empty($_POST['form_submitted']))
  17.  {
  18.   ?></font><p><font color="#4682B4 ">Please fill out the form:</font></p>
  19. <font color="#4682B4 "><?php
  20.  }
  21. */
  22. if (isset($_POST["form_submitted"]))
  23. {
  24. $name = $_POST['name'];
  25. $email = $_POST['email'];
  26. $subject = $_POST['subject'];
  27. $text = $_POST['text'];
  28. $merk = $_POST['merk'];
  29. $type = $_POST['type'];
  30. $bouwjaar = $_POST['bouwjaar'];
  31. $motorinhoud = $_POST['motorinhoud'];
  32. $kentekennummer = $_POST['kenteken nummer'];
  33.  
  34.  
  35.  
  36.  
  37.  
  38. unset($errors);
  39. if ($email != "" and !preg_match("/^[^@]+@.+\.\D{2,5}$/", $email)) $errors[] = "e-mail address lijkt incorrect";
  40. if ($text == "") $errors[] = "Geen bericht geplaatst";
  41. if ($_FILES['probe']['size'] > $max_attach_size) $errors[] = "Bijlage is te groot(".number_format($_FILES['probe']['size']/1000,0,",","")." KB) - maximum size: ".number_format($max_attach_size/1000,0,",","")." KB";
  42.  
  43. if (empty($errors))
  44. {
  45. $text = stripslashes($text);
  46. $subject = stripslashes($subject);
  47. if ($name != "") $mail_name=$name; else $mail_name="Unknown";
  48. if ($subject != "") $mail_subject = $subject; else $mail_subject = "No subject";
  49. if ($email != "") $mail_email = $email; else $mail_email = "email@unknown.xyz";
  50. if ($merk != "") $merk_merk=$merk; else $mail_merk="Unknown";
  51. if ($type != "") $type_type=$type; else $mail_type="Unknown";
  52. if ($bouwjaar != "") $bouwjaar_bouwjaar=$bouwjaar; else $mail_bouwjaar="Unknown";
  53.  
  54.  
  55. $ip = $_SERVER["REMOTE_ADDR"];
  56.  
  57. // if attachment, MIME-Mail:
  58. if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "")
  59. {
  60. // read and encode file:
  61. $datei_content = fread(fopen($_FILES['probe']['tmp_name'],"r"),filesize($_FILES['probe']['tmp_name']));
  62. $datei_content = chunk_split(base64_encode($datei_content),76,"\n");
  63. // Boundary:
  64. $boundary = md5(uniqid(rand()));
  65. // Mail-Header:
  66. $mail_header = "From: ".$mail_name." <".$mail_email.">\n";
  67. $mail_header .= "X-Sender-IP: ".$ip."\n";
  68. $mail_header .= "MIME-Version: 1.0\n";
  69. $mail_header .= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
  70. $mail_header .= "This is a multi-part message in MIME format.\n";
  71. // Mail-Text:
  72. $mail_header .= "--".$boundary;
  73. $mail_header .= "\nContent-Type: text/plain";
  74. $mail_header .= "\nContent-Transfer-Encoding: 8bit";
  75. $mail_header .= "\n\n".$text;
  76. // Attachment:
  77. $mail_header .= "\n--".$boundary;
  78. $mail_header .= "\nContent-Type: ".$_FILES['probe']['type']."; name=\"".$_FILES['probe']['name']."\"";
  79. $mail_header .= "\nContent-Transfer-Encoding: base64";
  80. $mail_header .= "\nContent-Disposition: attachment; filename=\"".$_FILES['probe']['name']."\"";
  81. $mail_header .= "\n\n".$datei_content;
  82. // End:
  83. $mail_header .= "\n--".$boundary."--";
  84. // Sende E-Mail und gebe Fehler bzw. Bestaetigung aus
  85. if (@mail($mailto,$mail_subject,"",$mail_header)) $sent = true; else $errors[] = "no connection to the mailserver - please try again later";
  86. }
  87. // no attachment, normal E-mail:
  88. else
  89. {
  90. $mail_header = "From: ".$mail_name." <".$mail_email.">\n";
  91. $mail_header .= "X-Sender-IP: $ip\n";
  92. $mail_header .= "Content-Type: text/plain";
  93. if (@mail($mailto,$mail_subject,$text,$mail_header)) $sent = true; else $errors[] = "no connection to the mailserver - please try again later";
  94. }
  95.  
  96. // copy to sender:
  97. if (isset($sent) && isset($email) && $email != "" && isset($_POST['copy']))
  98. {
  99. if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "") $copy_mail_text = "Copy of the e-mail:\n\n".$text."\n\nAttachment: ".$_FILES['probe']['name']; else $copy_mail_text = "Copy of the e-mail:\n\n".$text;
  100. $header= "From: ".$mailto."\n";
  101. $header .= "X-Sender-IP: ".$ip."\n";
  102. $header .= "Content-Type: text/plain";
  103. @mail($email, $mail_subject, $copy_mail_text, $header);
  104. }
  105. }
  106. }
  107.  
  108. if (empty($sent))
  109. {
  110. if(isset($errors))
  111. {
  112. ?></font><p class="caution"><font color="#4682B4 ">Error:</font></p><ul>
  113. <font color="#4682B4 "><?php foreach($errors as $f) { ?></font><li>
  114. <font color="#4682B4 "><?php echo $f; ?></li><?php } ?></font></ul>
  115. <font color="#4682B4 "><br /><?php
  116. }
  117.  
  118. ?></font><form method="post" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data"><div>
  119. <p><font color="#4682B4 "><span class="style2"><font face="Verdana" size="2">
  120. Naam</font></span><font face="Verdana" size="2"><span class="style2">:</span><br />
  121. </font>
  122. </font><font color="#4682B4 ">
  123. <input name="name" value="<?php if (isset($name)) echo htmlentities(stripslashes($name)); else echo ""; ?>" size="25" style="font-family: Verdana; border: 1px dashed #000000" />
  124. <font face="Verdana" size="2">
  125. <br />
  126. <span class="style2">E-mail:</span><br />
  127. </font>
  128. </font><font color="#4682B4 ">
  129. <input name="email" value="<?php if (isset($email)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="25" style="font-family: Verdana; border: 1px dashed #000000" />
  130. <font face="Verdana" size="2">
  131. <br />
  132. <span class="style2">Onderwerp:</span><br />
  133. </font>
  134. </font><font color="#4682B4 ">
  135. <input name="subject" value="<?php if (isset($subject)) echo htmlentities(stripslashes($subject)); else echo ""; ?>" size="25" style="font-family: Verdana; border: 1px dashed #000000" />
  136. <font face="Verdana" size="2">
  137. <br />
  138. <span class="style2">Bericht:</span><br />
  139. </font>
  140. </font><font color="#4682B4 ">
  141. <textarea name="text" cols="25" rows="7" style="font-family: Verdana; border: 1px dashed #000000"><?php if (isset($text)) echo htmlentities(stripslashes($text)); else echo ""; ?>
  142. </textarea>
  143. <font face="Verdana" size="2">
  144. <br><br><font color="#4682B4 "><strong>Aanvraag uitlaat of katalysator</strong></font><br>
  145. <br />
  146. <span class="style2">Merk:</span><br />
  147. </font>
  148. </font><font color="#4682B4 ">
  149. <input name="merk" value="<?php if (isset($merk)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="25" style="font-family: Verdana; border: 1px dashed #000000" />
  150. <font face="Verdana" size="2">
  151. <br />
  152. <span class="style2">type:</span><br />
  153. </font>
  154. </font><font color="#4682B4 ">
  155. <input name="type" value="<?php if (isset($type)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="25" style="font-family: Verdana; border: 1px dashed #000000" />
  156. <font face="Verdana" size="2">
  157. <br />
  158. <span class="style2">bouwjaar:</span><br />
  159. </font>
  160. </font><font color="#4682B4 ">
  161. <input name="bouwjaar" value="<?php if (isset($bouwjaar)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="25" style="font-family: Verdana; border: 1px dashed #000000" />
  162. <font face="Verdana" size="2">
  163. <br />
  164. <span class="style2">Motor inhoud:</span><br />
  165. </font>
  166. </font><font color="#4682B4 ">
  167. <input name="bouwjaar" value="<?php if (isset($motorinhoud)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="25" style="font-family: Verdana; border: 1px dashed #000000" />
  168. <font face="Verdana" size="2">
  169. <br />
  170. <span class="style2">Kenteken nummer:</span><br />
  171. </font>
  172. </font><font color="#4682B4 ">
  173. <input name="bouwjaar" value="<?php if (isset($kentekennummer)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="25" style="font-family: Verdana; border: 1px dashed #000000" />
  174. <font face="Verdana" size="2"><br><br>
  175.  
  176. <span class="style2">Bijlagen:</span><br />
  177. </font>
  178. </font><font color="#4682B4 ">
  179. <input type="file" name="probe" value="<?php if (isset($_POST['probe'])) echo htmlentities(stripslashes($_POST['probe'])); else echo ""; ?>" size="16" style="font-family: Verdana; border: 1px dashed #000000"/>
  180. </font>
  181. <p><font color="#4682B4 ">Heeft u een auto, maar weet niet welke uitlaat hieronder past?<br>
  182. Upload een afbeelding, en wij zoeken voor u een gepaste uitlaat.</font></p>
  183. </p>
  184. </p>
  185. <p><font face="Verdana"><font color="#4682B4 "><input type="checkbox" name="copy" value="true" /></font><font size="2" color="#4682B4 ">
  186. <span class="style2">Kopie naar jezelf sturen?</span> </font></font>
  187. <font color="#4682B4 ">
  188. <input type="submit" name="form_submitted" value="OK - Verzenden" style="font-family: Verdana; border: 1px dashed #000000" /></font><font face="Verdana" size="2" color="#4682B4 ">
  189. </font> </p>
  190. </div>
  191. </form><font color="#4682B4 "><?php
  192. }
  193. else
  194. {
  195. if (empty($email)) { ?></font></font><font color="#4682B4 "> </font>
  196. <p><font color="#4682B4 "><b><font face="Verdana" size="1">Bedankt</font></b><font size="1" face="Verdana"><b>!</b><br />
  197. Je mail is verzonden alleen kan ik je niet terug mailen omdat je geen e-mail
  198. adres hebt ingevuld! </font></font></p>
  199. <font face="Verdana" size="1"><font color="#4682B4 "><?php }
  200. else { ?></font></font><font color="#4682B4 "> </font>
  201. <p><font color="#4682B4 "><b><font face="Verdana" size="1">Bedankt</font></b><font size="1" face="Verdana"><b>!</b><br />
  202. Je bericht is met succes verzonden ik zal zo spoedig mogelijk terug mailen. </font>
  203. </font></p>
  204. <font face="Verdana" size="1" color="#4682B4 "><?php }
  205. }
  206.  
  207.  
  208. ?>

2 antwoorden

Gesponsorde links
Offline larssy1 - 09/02/2010 16:33 (laatste wijziging 09/02/2010 16:48)
Avatar van larssy1 MySQL beginner gebruik aub code tags...je begint 'm wel, maar sluit 'm niet af...

---
Oké bedankt voor t aanpassen, en ik heb je probleem gevonden.

Je if structuur op regel47 klopt niet
je gebruikt de } en { tags niet..

jij doet 't op de volgende manier:
  1. if($name == "hello")
  2. $id = "american dad";
  3. else
  4. $id = "gigity";


inplaats van
  1. if($name == "hello"){
  2. $id = "american dad";
  3. }else{
  4. $id = "gigity";}


Let op! dit geldt voor regel 47,48,49 en 50
Offline Darklevi - 09/02/2010 17:07 (laatste wijziging 09/02/2010 18:19)
Avatar van Darklevi Lid Naam onderwep Bericht werk nu. de rest heb ik zelf toegevoegd maar die werken niet. Hoe zorg ik ervoor dat die ook worden verzonden?

Mvg,

Levi

  1. $text .= ''.$mail_text."\n"."\n";
  2. $text .= 'merk: '.$mail_merk."\n";
  3. $text .= 'type: '.$mail_type."\n";
  4. $text .= 'bouwjaar: '.$mail_bouwjaar."\n";
  5. $text .= 'motorinhoud: '.$mail_motorinhoud."\n";
  6. $text .= 'kentekennummer: '.$mail_kentekennummer."\n";
fixed
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.229s