re probleme formulaire php

re probleme formulaire php - PHP - Programmation

Marsh Posté le 28-02-2008 à 14:40:47    

ok dridri je savais pas comment faire  
 voila c'est vrai c'est+ lisible ...merci  
 
 
bonjour  
suite au probleme avec le cgi je suis retourné au php mais n'etant pas un as en programmation j'ai quelques soucis  
j'ai un formulaire en html qui fait appel a un script php qui revoie a une page    
remerciement/erreur.. cela marche dans l'absolu et je recois les reponses...  
par contre 2 problemes persitent:  
1 la verif (adresse email par ex.)demandé ne marche pas( donc jamais de page erreur!!!)  
2 sur le message de remerciement j'aurais voulu integrer  la civilité et le nom  
et aussi nada!!!  
   
les codes page topformhtml:  

Code :
  1. div>
  2.   <div id="blocform">
  3. <Form METHOD="POST"ACTION="http://www.toto.com/test/form2mail.php" >
  4.      <input type="hidden" value="success.shtml" name="success" />
  5.   <input type="hidden" value="failure.shtml" name="failure" />
  6.   <input type="hidden" value="toto" name="titresite" />
  7.   <input type="hidden" value="Contact " name="subject" />


   
codespage form.html  
 

Code :
  1. <p />
  2. <p align="left"><span class="ContText"><b>Contacter </b></span></p>
  3. <p align="left"><span class="FormText">Civilit&eacute; * : <input type="radio" value="Madame" name="civilitees" class="intext" /> Madame <input type="radio" value="Mademoiselle" name="civilitees" class="intext" /> Mademoiselle <input type="radio" value="Monsieur" name="civilitees" class="intext" /> Monsieur.</span></p>
  4.   <hr />
  5. <p align="left" class="ContText">Votre Nom <span class="FormText">*</span> :<br /><input type="text" name="required-Votre-Nom" size="24" style="width:99%" class="intext" /></p>
  6. <p align="left" class="ContText">Votre Pr&eacute;nom :<br /><input type="text" name="Votre-Prenom" size="24" style="width:99%" class="intext" /></p>
  7. <p align="left" class="ContText">Votre adresse email <span class="FormText">*</span> :<br /><input type="text" name="required-email" size="24" style="width:99%" class="intext" /></p>
  8.    <p align="left" class="ContText">
  9.    Merci de s&eacute;lectionner un statut en utilisant le menu ci-dessous ! <span class="FormText">*</span>
  10.    <select name="required-Statut" size="1" style="width:auto">
  11.     <option value="aucun">Vous &ecirc;tes ...</option>
  12.     <option value="Particulier">Particulier</option>
  13.     <option value="Profession libŽrale">Profession lib&eacute;rale</option>
  14.     <option value="Entreprise">Entreprise</option>
  15.     <option value="Association">Association</option>
  16.     <option value="Administration et collectivitŽ">Administration et collectivit&eacute;</option>
  17.     <option value="Autre">Autre</option>
  18.    </select></p>
  19. <p align="left" class="ContText">Pr&eacute;ciser le nom de l'entreprise, association, collectivit&eacute; ...  <br /><input type="text" name="entreprise" size="24" style="width:99%" class="intext" /></p>
  20. <p align="left" class="ContText">Contenu du message <span class="FormText">*</span> :<br /><textarea name="message" cols="40" rows="10" style="font-size:10pt;width:99%" class="intext"></textarea></p>
  21.   <p align="center"><input type="reset" value="effacer" class="select" style="width:45%" /> <input type="submit" value="envoyer ce message" class="select" style="width:45%" /></p>
  22. </form>
  23.   </div>


 
 
 
le code form2mail.php  

Code :
  1. <?php
  2. # You can use this script to submit your forms or to receive orders by email.
  3. $MailToAddress = "toto@toto.com"; // your email address
  4. $redirectURL = "http://www.toto.com/test/success.shtml"; // the URL of the thank you page.
  5. $MailSubject = "[Message from the contact form]"; // the subject of the email
  6. $sendHTML = FALSE; //set to "false" to receive Plain TEXT e-mail
  7. $serverCheck = TRUE; // if, for some reason you can't send e-mails, set this to "false"
  8. # copyright 2006 Web4Future.com =================== READ THIS ===================================================
  9. # If you are asking for a name and an email address in your form, you can name the input fields "name" and "email".
  10. # If you do this, the message will apear to come from that email address and you can simply click the reply button to answer it.
  11. # To block an IP, simply add it to the blockip.txt text file.
  12. # CHMOD 777 the blockip.txt file (run "CHMOD 777 blockip.txt", without the double quotes)
  13. # This is needed because the script tries to block the IP that tried to hack it
  14. # If you have a multiple selection box or multiple checkboxes, you MUST name the multiple list box or checkbox as "name[]" instead of just "name"
  15. # you must also add "multiple" at the end of the tag like this: <select name="myselectname[]" multiple>
  16. # you have to do the same with checkboxes
  17. /*****************************************************************
  18. Web4Future Easiest Form2Mail (GPL).
  19. Copyright (C) 1998-2006 Web4Future.com All Rights Reserved.
  20. This script was written by George L. & Calin S. from Web4Future.com
  21. This program is free software; you can redistribute it and/or modify
  22. it under the terms of the GNU General Public License as published by
  23. the Free Software Foundation; either version 2 of the License, or
  24. (at your option) any later version.
  25. This program is distributed in the hope that it will be useful,
  26. but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  28. GNU General Public License for more details.
  29. *****************************************************************/
  30. # DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ===================================================
  31. $w4fver =  "2.2";
  32. $ip = ($_SERVER['HTTP_X_FORWARDED_FOR'] == "" ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_FORWARDED_FOR']);
  33. //function blockIP
  34. function blockip($ip) {
  35. $handle = @fopen("blockip.txt", 'a');
  36. @fwrite($handle, $ip."\n" );
  37. @fclose($handle);
  38. }
  39. $w4fx = stristr(file_get_contents('blockip.txt'),getenv('REMOTE_ADDR'));
  40. if ($serverCheck) {
  41. if (preg_match ("/".str_replace("www.", "", $_SERVER["SERVER_NAME"])."/i", $_SERVER["HTTP_REFERER"])) { $w4fy = TRUE; } else { $w4fy = FALSE; }
  42. } else { $w4fy = TRUE; }
  43. if (($w4fy === TRUE) && ($w4fx === FALSE)) {
  44. $w4fMessage = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body><font face=3Dverdana size=3D2>";
  45. if (count($_GET) >0) {
  46. reset($_GET);
  47. while(list($key, $val) = each($_GET)) {
  48.  $GLOBALS[$key] = $val;
  49.  if (is_array($val)) {
  50.   $w4fMessage .= "<b>$key:</b> ";
  51.   foreach ($val as $vala) {
  52.    $vala =stripslashes($vala);
  53.    $vala = htmlspecialchars($vala);
  54.    if (trim($vala)) { if (stristr($vala,"Content-Type:" ) || stristr($vala,"MIME-Version" ) || stristr($vala,"Content-Transfer-Encoding" ) || stristr($vala,"bcc:" )) { blockip($ip); die("ILLEGAL EXECUTION DETECTED!" ); } }
  55.    $w4fMessage .= "$vala, ";
  56.   }
  57.   $w4fMessage .= "<br>\n";
  58.  }  
  59.  else {
  60.   $val = stripslashes($val);
  61.   if (trim($val)) { if (stristr($val,"Content-Type:" ) || stristr($val,"MIME-Version" ) || stristr($val,"Content-Transfer-Encoding" ) || stristr($val,"bcc:" )) { blockip($ip); die("ILLEGAL EXECUTION DETECTED!" ); } }
  62.   if (($key == "Submit" ) || ($key == "submit" )) { }  
  63.   else {  if ($val == "" ) { $w4fMessage .= "$key: - <br>\n"; }
  64.     else { $w4fMessage .= "<b>$key:</b> $val<br>\n"; }
  65.   }
  66.  }
  67. } // end while
  68. }//end if
  69. else {
  70. reset($_POST);
  71. while(list($key, $val) = each($_POST)) {
  72.  $GLOBALS[$key] = $val;
  73.  if (is_array($val)) {
  74.   $w4fMessage .= "<b>$key:</b> ";
  75.   foreach ($val as $vala) {
  76.    $vala =stripslashes($vala);
  77.    $vala = htmlspecialchars($vala);
  78.    if (trim($vala)) { if (stristr($vala,"Content-Type:" ) || stristr($vala,"MIME-Version" ) || stristr($vala,"Content-Transfer-Encoding" ) || stristr($vala,"bcc:" )) {blockip($ip); die("ILLEGAL EXECUTION DETECTED!" ); } }    
  79.    $w4fMessage .= "$vala, ";
  80.   }
  81.   $w4fMessage .= "<br>\n";
  82.  }  
  83.  else {
  84.   $val = stripslashes($val);
  85.   if (trim($val)) { if (stristr($val,"Content-Type:" ) || stristr($val,"MIME-Version" ) || stristr($val,"Content-Transfer-Encoding" ) || stristr($val,"bcc:" )) {blockip($ip); die("ILLEGAL EXECUTION DETECTED!" ); } }
  86.   if (($key == "Submit" ) || ($key == "submit" )) { }  
  87.   else {  if ($val == "" ) { $w4fMessage .= "$key: - <br>\n"; }
  88.     else { $w4fMessage .= "<b>$key:</b> $val<br>\n"; }
  89.   }
  90.  }
  91. } // end while
  92. }//end else
  93. $w4fMessage .= "<font size=3D1><br><br>\n Sender IP: ".$ip."</font></font></body></html>";
  94.    $w4f_what = array("/To:/i", "/Cc:/i", "/Bcc:/i","/Content-Type:/i","/\n/" );
  95. $name = preg_replace($w4f_what, "", $name);
  96. $email = preg_replace($w4f_what, "", $email);
  97. if (!$email) {$email = $MailToAddress;}
  98. $mailHeader = "From: $name <$email>\r\n";
  99. $mailHeader .= "Reply-To: $name <$email>\r\n";
  100. $mailHeader .= "Message-ID: <". md5(rand()."".time()) ."@". ereg_replace("www.","",$_SERVER["SERVER_NAME"]) .">\r\n";
  101. $mailHeader .= "MIME-Version: 1.0\r\n";
  102. if ($sendHTML) {
  103.  $mailHeader .= "Content-Type: multipart/alternative;";  
  104.  $mailHeader .= "  boundary=\"----=_NextPart_000_000E_01C5256B.0AEFE730\"\r\n";    
  105. }
  106. $mailHeader .= "X-Priority: 3\r\n";
  107. $mailHeader .= "X-Mailer: PHP/" . phpversion()."\r\n";
  108. $mailHeader .= "X-MimeOLE: Produced By Web4Future Easiest Form2Mail $w4fver\r\n";
  109. if ($sendHTML) {
  110.  $mailMessage = "This is a multi-part message in MIME format.\r\n\r\n";
  111.  $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730\r\n";
  112.  $mailMessage .= "Content-Type: text/plain;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";  
  113.  $mailMessage .= trim(strip_tags($w4fMessage))."\r\n\r\n";  
  114.  $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730\r\n";  
  115.  $mailMessage .= "Content-Type: text/html;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";  
  116.  $mailMessage .= "$w4fMessage\r\n\r\n";  
  117.  $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730--\r\n";  
  118. }
  119. if ($sendHTML === FALSE) {
  120.  $mailHeader .= "Content-Type: text/plain;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";  
  121.  $mailMessage .= trim(strip_tags($w4fMessage))."\r\n\r\n";  
  122. }
  123. if (!mail($MailToAddress, $MailSubject, $mailMessage,$mailHeader)) { echo "Error sending e-mail!";}
  124. else { header("Location: ".$redirectURL); }
  125. } else { echo "<center><font face=verdana size=3 color=red><b>ILLEGAL EXECUTION DETECTED!</b></font></center>";}
  126. ?>


et pour fini la page remerciement  
 

Code :
  1. <div id="main">  <!-- debut #main -->
  2. <div id="container">
  3. <div id="bloctext1">
  4. <h3>Avec nos remerciements...</h3>
  5. <p><h3><b>[civilitees] [required-Votre-Nom]</b>, nous venons d'enregistrer votre demande.</h3>
  6.   </p>
  7.   <p><span class="FormText">r&eacute;f&eacute;rence : [$REMOTE_ADDR].[$REMOTE_HOST]<br />[$HTTP_USER_AGENT]</span></p>
  8. </div>
  9. </div>


 
 
 
voila c'est un peu du bricolage je crois? mais si quelqu'un a une idée je suis preneur  
pascal  
 

Reply

Marsh Posté le 28-02-2008 à 14:40:47   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed