Formulaire PHP
Résolu
Maknash
Messages postés
646
Date d'inscription
Statut
Membre
Dernière intervention
-
avion-f16 Messages postés 19252 Date d'inscription Statut Contributeur Dernière intervention -
avion-f16 Messages postés 19252 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Je suis en train de faire un formulaire PHP où l'on choisi via un bouton radio à qui on envoie le mail.
Seulement j'ai beau remplir le formulaire ça ne va pas.
A mon avis j'ai oublié un truc mais j'arrive pas à voir quoi. En fait ma variable $contact ne renvoie rien apparemment.
Voici mon code :
Merci d'avance
Je suis en train de faire un formulaire PHP où l'on choisi via un bouton radio à qui on envoie le mail.
Seulement j'ai beau remplir le formulaire ça ne va pas.
A mon avis j'ai oublié un truc mais j'arrive pas à voir quoi. En fait ma variable $contact ne renvoie rien apparemment.
Voici mon code :
<?php session_start(); if ( isset($_GET['image']) ) { $alphanum = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789"; $rand = substr(str_shuffle($alphanum), 0, 5); $_SESSION['image_random_value'] = md5($rand); $image = imagecreate(60,18); $bgColor = imagecolorallocate ($image, 255, 255, 255); $textColor = imagecolorallocate ($image, 0, 0, 0); imagestring ($image, 5, 5, 2, $rand, $textColor); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header('Content-type: image/jpeg'); imagejpeg($image); imagedestroy($image); exit; } function EmailOK($email) { if(preg_match('`^:alnum:([-_.]?:alnum:)*@:alnum:([-_.]?:alnum:)*\.([a-z]{2,4})$`',$email)) { return true; } else { return false; } } if(!empty($_POST['auteur']) || !empty($_POST['web'])) { // a config define(MAXNOM, 30); define(MAXPRE, 30); define(MAXCOMM, 300); extract($_POST,EXTR_OVERWRITE); $_POST = addslashes($_POST); $erreur=''; if(empty($nom) || strlen($nom) > MAXNOM) { $erreur .= '<b class="Style11"> <br /> Le champs "Nom" doit être rempli et faire MAXIMUM 30 caractères'; } if(empty($prenom) || strlen($prenom) > MAXPRE) { $erreur .= '<b class="Style11"> <br /> Le champs "Prénom" doit être rempli et faire MAXIMUM 30 caractères'; } if(!EmailOK($mail)) { $erreur .= '<b class="Style11"> <br /> L\'adresse email est incorrecte'; } if(empty($sujet)) { $erreur .= '<b class="Style11"> <br /> Veuillez choisir un sujet SVP'; } if(empty($commentaires) || strlen($commentaires) > MAXCOMM) { $erreur .= '<b class="Style11"> <br /> Le champs message doit être rempli et faire MAXIMUM 300 caractères'; } if(md5($code) != $_SESSION['image_random_value'] ) { $erreur .= '<b class="Style11"> <br /> Le code anti-robot est invalide'; } if(empty($erreur)) {// envoi mail $to = ($contact == 1) ? 'mathiasjoann@aol.com' : 'imbrechts.kevin@gmail.com'; //echo $contact; $subject = "Contact Siligan-Nostromo"; $message = ' <b>Contact Siligan-Nostromo</b> <br> Nom : '.$nom.'<br> Prenom : '.$prenom.'<br> EMail : '.$mail.'<br> Sujet : '.$sujet.'<br> Message : '.$commentaires.'<br> <br><br> '; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: Siligan Nostromo<imbrechts.kevin@gmail.com>"; mail($to, $subject, $message, $headers); $fin = '<b class="Style11"> Votre message a bien été envoyer'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="Contacter l’auteur ou le webmaster, siligan nostromo, joann mathias, mathias, poèmes, poetes, écrivain, synthetic-nervosia, synthétic nervosia, jeune ecrivain, romans, news, biographie, oeuvres, photos, contacts, liens"/> <meta name="description" content="Site officiel de l'écrivain Joann Mathias, poèmes et romans, influencé par Damien Saez et Charles Baudelaire. Contacter l’auteur ou le webmaster"/> <meta name="author" content="Imbrechts Kevin"/> <title>Siligan Nostromo :: Site officiel de l'écrivain Joann MATHIAS :: Contacts</title> <link href="menu.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="images/fav.ico" /> <style type="text/css"> <!-- .Style12 {color: #FF0000} --> </style> </head> <body> <p> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script></p> <div align="center"> <table id="Table_01" width="789" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="8"><div align="center"><img src="cadres/index_01.png" width="757" height="159" alt="Bannière Siligan Nostromo" title="Bannière Siligan Nostromo" /></div></td> <td width="27" rowspan="7"> </td> </tr> <tr> <td colspan="3"><div align="center"><img src="cadres/index_03.png" alt="" width="175" height="163" /></div></td> <td width="283" height="158" rowspan="2"><script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0','width','283','height','158','movie','header','quality','high','bgcolor','#000000','pluginspage','http://www.macromedia.com/go/getflashplayer' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload2.macromedia.com/get/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="283" height="158"> <param name="movie" value="header.swf" /> <param name="quality" value="high" /> <param name="BGCOLOR" value="#000000" /> <param name="width" value="283" /> <param name="height" value="158" /> <param name="pluginspage" value="https://get.adobe.com/flashplayer/" /> </object> </noscript> </td> <!-- Pour que IE ne lise pas le code qui suit --> <!--[if !IE]> <!--> <td height="158" colspan="2" rowspan="2" valign="top" style="background-image:url('cadres/index_05.jpg');" > <div align="center"> <table border="0" align="center" cellpadding="2" cellspacing="0"> <tr valign="top"> <td height="26" valign="middle"> </td> <td width="132" align="left" valign="middle"> <a href="index.html" class="Style9"><b class="Style1">Home</b></a></td> </tr> <tr valign="top"> <td height="28" valign="middle"> </td> <td align="left" valign="middle"> <a href="biographie.html" class="Style9"><span class="Style1"><b class="Style1">Biographie</b></span></a></td> </tr> <tr valign="top"> <td height="29" valign="middle"> </td> <td align="left" valign="middle"> <a href="photos.html" class="Style9"><span class="Style1"><s><b class="Style1">Photos</b></s></span></a></td> </tr> <tr valign="top"> <td valign="middle"> </td> <td align="left" valign="middle"> <a href="oeuvres.html" class="Style9"><span class="Style1"><b class="Style1">Œuvres</b><b></b> </span></a></td> </tr> <tr valign="top"> <td height="28" valign="middle"> </td> <td align="left" valign="middle"> <a href="contacts.php" class="Style9"><span class="Style1"><b class="Style1">Contacts</b></span></a></td> </tr> <tr valign="top"> <td height="22" valign="middle"> </td> <td align="left" valign="middle"> <a href="liens.html" class="Style9"><span class="Style1"><b class="Style1">Liens</b><b></b></span></a></td> </tr> </table> </div></td> <!--> <![endif]--> <!-- Pour que IE lise pas le code qui suit --> <!--[if IE]> <td height="158" colspan="2" rowspan="2" valign="top" background="cadres/index_05.jpg" > <div align="center"> <table border="0" align="center" cellpadding="2" cellspacing="0"> <tr valign="top"> <td height="23" valign="middle"> </td> <td width="132" align="left" valign="middle"> <a href="index.html" class="Style9"><b class="Style1">Home</b></a></td> </tr> <tr valign="top"> <td height="23" valign="middle"> </td> <td align="left" valign="middle"> <a href="biographie.html" class="Style9"><span class="Style1"><b class="Style1">Biographie</b><b></b> </span></a></td> </tr> <tr valign="top"> <td height="23" valign="middle"> </td> <td align="left" valign="middle"> <a href="photos.html" class="Style9"><span class="Style1"><b class="Style1">Photos</b><b></b> </span></a></td> </tr> <tr valign="top"> <td valign="middle"> </td> <td align="left" valign="middle"> <a href="oeuvres.html" class="Style9"><span class="Style1"><b class="Style1">Œuvres</b><b></b> </span></a></td> </tr> <tr valign="top"> <td height="28" valign="middle"> </td> <td align="left" valign="middle"> <a href="contacts.html" class="Style9"><span class="Style1"><b class="Style1">Contacts</b><b></b></span></a></td> </tr> <tr valign="top"> <td height="22" valign="middle"> </td> <td align="left" valign="middle"> <a href="liens.html" class="Style9"><span class="Style1"><b class="Style1">Liens</b><b></b></span></a></td> </tr> </table> </div></td> <![endif]--> <td colspan="2" rowspan="2"><div align="center"><img src="cadres/index_06.png" width="121" height="163" alt="" /></div></td> </tr> <tr> <td width="132" rowspan="3"> </td> <td colspan="2"> <img id="index_08" src="imgs/index_08.jpg" width="43" height="1" alt="" /></td> </tr> <tr> <td> <img id="index_09" src="imgs/index_09.jpg" width="26" height="1" alt="" /></td> <td height="63" colspan="3" rowspan="2" align="center" valign="bottom" background="imgs/index_10.jpg"><div align="center"><span class="Style9"><img src="cadres/index_10.png" width="481" height="63" alt="" /></span></div></td> <td colspan="3" rowspan="2"><img src="cadres/index_11.png" alt="" width="123" height="63" /></td> </tr> <tr> <td><div align="right"><img src="cadres/index_12.jpg" alt="" width="23" height="63" /></div></td> </tr> <tr> <td bgcolor="#000000"> </td> <td width="26" style="background-image:url('cadres/index_14.jpg');" /> </td> <td colspan="3" align="center" valign="middle" bgcolor="#000000"> <h1>Contacts</h1> <p><img src="images/sol.jpg" alt="Photo d'un sol mouillé. Copyright Helene Chaulieu." title="Photo d'un sol mouillé. Copyright Helene Chaulieu." width="480" height="244" /></p> <h2>contacter</h2> <?php ///////AFFICHAGE DES ERREURS ////////// if(!empty($fin)) { echo $fin; }else { if(!empty($erreur)) { echo $erreur; } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p align="justify" class="Style11"> <TABLE width="438" BORDER=0> <TR> <TD width="152" class="Style11"><p>Qui voulez-vous contacter ?</p> <p>Nom :</p></TD> <TD class="Style11"width="276"> L'auteur : <INPUT type=radio name="contact" value="0" checked="checked"> <br>Le webmaster : <INPUT type=radio name="contact" value="1"> <p> <INPUT type=text name="nom" class="Style11"> </p></TD> </TR> <TR> <TD class="Style11">Prénom :</TD> <TD> <INPUT type=text name="prenom" class="Style11"> </TD> </TR> <TR> <TD class="Style11">Adresse mail :</TD> <TD> <INPUT type=text name="mail" class="Style11"> </TD> </TR> <TR> <TD class="Style11">Sexe :</TD> <TD class="Style11"> Homme : <INPUT type=radio name="sexe" value="M" checked="checked"> <br> Femme : <INPUT type=radio name="sexe" value="F"> </TD> </TR> <TR> <TD class="Style11">Sujet du message :</TD> <TD> <select name="sujet" class="Style11"> <option value="">Choisissez un sujet ici :</option> <option value="encouragements">Encouragements</option> <option value="professionnel">Professionnel</option> <option value="questions">Questions</option> <option value="autre">Autre</option> </select> </TD> </TR> <TR> <TD class="Style11">Votre message :</TD> <TD><textarea name="commentaires" cols="30" rows="8" class="Style11"></textarea></TD> </TR> <TR> <TD class="Style11">Recopier le code anti-robot <span class="Style12">(Veillez à respecter la casse SVP)</span></TD> <TD> <img src="contacts.php?image" alt="" /><br /> <input type="text" name="code" class="Style11" /> </TD> </TR> <TR> <TD COLSPAN=2 align="center"> <input type="hidden" name="auteur" value="ok" /> <INPUT type="submit" value="Envoyer"> <input name="Reset" type="reset" value="Réinitialiser" /> </TD> </TR> </TABLE> </p> </form> <!-- <?php } ?> <h2>contacter le webmaster</h2> <?php ///////AFFICHAGE DES ERREURS ////////// if(!empty($fin)) { echo $fin; }else { if(!empty($erreur)) { echo $erreur; } ?> <form method="post" action="contacts.html"> <p align="justify" class="Style11"> <TABLE width="438" BORDER=0> <TR> <TD width="141" class="Style11">Nom :</TD> <TD width="303"> <INPUT type=text name="nom" class="Style11"> </TD> </TR> <TR> <TD class="Style11">Prénom :</TD> <TD> <INPUT type=text name="prenom" class="Style11"> </TD> </TR> <TR> <TD class="Style11">Adresse mail :</TD> <TD> <INPUT type=text name="mail" class="Style11"> </TD> </TR> <TR> <TD class="Style11">Sexe :</TD> <TD class="Style11"> Homme : <INPUT type=radio name="sexe" value="M" > <br> Femme : <INPUT type=radio name="sexe" value="F"> </TD> </TR> <TR> <TD class="Style11">Sujet du message :</TD> <TD><select name="sujet" class="Style11"> <option value="sujet">Choisissez un sujet ici :</option> <option value="encouragements">Bugs rencontrés</option> <option value="professionnel">Professionnel</option> <option value="questions">Questions</option> <option value="autre">Autre</option> </select> </TD> </TR> <TR> <TD class="Style11">Votre message :</TD> <TD> <textarea name="commentaires" cols="30" rows="8" class="Style11"></textarea> </TD> </TR> <TR> <TD class="Style11">Recopier le code anti-robot </TD> <TD> <img src="contacts.html?image" alt="" /><br /> <input type="text" name="code" class="Style11" /> </TD> </TR> <TR> <TD COLSPAN=2 align="center"> <INPUT type="submit" value="Envoyer"> <input type="hidden" name="web" value="ok" /> <input name="Reset" type="reset" value="Réinitialiser" /> </TD> </TR> </TABLE> </p> </form>--> <?php } ?></td> <td colspan="2" style="background-image:url('cadres/index_16.jpg'); background-repeat:repeat-y;"> </td> <td width="98" bgcolor="#000000"> </td> </tr> <tr> <td> </td> <td colspan="2"> <img src="cadres/index_19.jpg" width="43" height="82" /></td> <td height="82" colspan="4" valign="bottom" background="cadres/index_20.jpg"><div align="center"><span class="Style9">Siligan Nostromo © 2008 by Imbrechts Kevin</span></div></td> <td> </td> </tr> <tr> <td> <img src="imgs/espaceur.gif" width="132" height="1" alt="" /></td> <td> <img src="imgs/espaceur.gif" width="26" height="1" alt="" /></td> <td width="17"> <img src="imgs/espaceur.gif" width="17" height="1" alt="" /></td> <td> <img src="imgs/espaceur.gif" width="283" height="1" alt="" /></td> <td width="181"> <img src="imgs/espaceur.gif" width="181" height="1" alt="" /></td> <td width="4"> <img src="imgs/espaceur.gif" width="4" height="1" alt="" /></td> <td width="21"> <img src="imgs/espaceur.gif" width="21" height="1" alt="" /></td> <td> <img src="imgs/espaceur.gif" width="98" height="1" alt="" /></td> <td> <img src="imgs/espaceur.gif" width="18" height="1" alt="" /></td> </tr> </table> <!-- End ImageReady Slices --> </div> </body> </html>
Merci d'avance
A voir également:
- Formulaire PHP
- Whatsapp formulaire opposition - Guide
- Formulaire de réclamation facebook - Guide
- Formulaire de reclamation instagram - Guide
- Easy php - Télécharger - Divers Web & Internet
- Confirmer le nouvel envoi du formulaire err_cache_miss - Forum Webmastering
$contact existe vu qu'il ajoute cette ligne dans le php:
extract($_POST,EXTR_OVERWRITE);
;)