Ok so I want people to fill in a form and when they press submit it gets sent to my email address... Everything is working fine I just need to know how to make the checkbox appear in my email, the free script I used didn't have any checkbox and I don't know how to write them
Here's my PHP code:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "mymail";
$email_subject = "Un nouveau formulaire est rempli";
function died($error) {
// your error code can go here
echo "Il semble y avoir une erreur avec le formulaire que vous tentez d'envoyer.";
echo "Voici ces erreurs:.<br /><br />";
echo $error."<br /><br />";
echo "Merci de les corriger avant de tenter de renvoyer le formulaire.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['prenom']) ||
!isset($_POST['nom']) ||
!isset($_POST['sexe']) ||
!isset($_POST['telephone']) ||
!isset($_POST['email']) ||
!isset($_POST['experience'])) {
died('Il semble y avoir une erreur avec le formulaire que vous tentez d\'envoyer.');
}
$prenom = $_POST['prenom']; // required
$nom = $_POST['nom']; // required
$sexe = $_POST['sexe']; // not required
$telephone = $_POST['telephone']; // not required
$email = $_POST['email']; // required
$experience = $_POST['experience']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {
$error_message .= 'Votre adresse courriel est invalide.<br />';
}
if(strlen($experience) < 2) {
$error_message .= 'Veuillez écrire votre expertise dans la section réversée à cette fin.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
} $email_message = "Formulaire rempli:.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Prenom: ".clean_string($prenom)."\n";
$email_message .= "Nom: ".clean_string($nom)."\n";
$email_message .= "Sexe: ".clean_string($sexe)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Courriel: ".clean_string($email)."\n";
$email_message .= "Experience et Expertise: ".clean_string($experience)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?><!-- include your own success html here --> Merci d'avoir pris le temps de remplir le formulaire! Nous vous contacterons le plus rapidement possible. <?php } ?>
Here's my HTML:
<form id="DevenirBenevole" name="DevenirBenevole" method="post" action="scripts/benevoleformulaire.php">
<table width="90%" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td width="45%" align="right" class="TxtContenuRight"><label>Prénom:</label></td>
<td width="55%" align="left"><input type="text" name="prenom" id="prenom" /></td>
</tr>
<tr>
<td width="45%" align="right" class="TxtContenuRight"><label>Nom:</label></td>
<td width="55%" align="left"><input type="text" name="nom" id="nom" /></td>
</tr>
<tr>
<td align="right" class="TxtContenuRight"><label>Je suis:</label></td>
<td align="left"><span class="TxtContenuRight">
<select name="sexe" size="1" class="TxtContenu" id="sexe">
<option value="homme" selected="selected">un homme</option>
<option value="femme">une femme</option>
</select>
</span></td>
</tr>
<tr>
<td width="45%" align="right" class="TxtContenuRight"><label>Numéro de téléphone:</label></td>
<td width="55%" align="left"><input type="text" name="telephone" id="telephone" /></td>
</tr>
<tr>
<td align="right" class="TxtContenuRight"><span class="TxtContenu">Courriel:
</span></td>
<td align="left"><input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td width="45%" align="right" valign="top" class="TxtContenuRight"><table width="66%" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td height="auto" class="TxtContenuRight">Veuillez cocher les domaines qui vous intéresse le plus:</td>
</tr>
</table></td>
<td width="55%" align="left" valign="top"><p class="TxtContenu">
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="Accueil" /></label>
<span class="TxtContenuBold">Accueil </span><br />
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="ComiteDeveloppement" />
<span class="TxtContenuBold">Comité de développement</span></label>
<br />
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="ComiteFinance" />
<span class="TxtContenuBold">Comité de finances </span></label>
<br />
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="ComiteCulturel" />
<span class="TxtContenuBold">Comité Culturel </span></label>
<br />
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="ComiteSocial" /></label>
<span class="TxtContenuBold">Comité Social </span><br />
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="ComiteProgrammation" />
<span class="TxtContenuBold">Comité de Programmation</span><br />
</label>
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="ComiteVoyages" />
<span class="TxtContenuBold">Comité de Voyages et Sorties</span></label>
<br />
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="ComiteChorale" />
<span class="TxtContenuBold">Comité de la Chorale </span></label>
<br />
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="ComiteBridge" /></label>
<span class="TxtContenuBold">Comité de bridge </span><br />
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="BingoFriends" />
<span class="TxtContenuBold">Bingo Friends</span><br />
</label>
<br />
<label>
<input type="checkbox" name="DomaineInteret" value="checkbox" id="25eme" />
<span class="TxtContenuBold">25ième anniversaire du CSMO </span></label>
<br />
</p></td>
</tr>
Thank you very much for your help!