PDA

View Full Version : Help PHP checkbox multiple choises


claroquetengo
04-29-2011, 05:01 AM
Hi, I have a form that potential clients fill out and an email is sent to me. On the form I have multiple checkboxes. I can't figure out how to get the checkboxes information to send in the email. The potential clients are able to select as many boxes as they would like. How do I set up the php (http://www.webdeveloper.com/forum/showthread.php?t=117364#) file to accept multiple checkbox inputs and send it cleanly in an email. I have seen the serialize and so forth but don't understand how to unserialize into the email.


Inscription.php

<form method="post" action="sendeail.php">

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />

<img src="img/bineta.gif" width="24" height="17" border="0" />
Nom de l'Enfant: <br />
<input type="text" name="enfant" size="45" />
<br />
Date de Naissance: (dd-mm-aaaa)<br />
<input type="text" name="naissance" size="45" />
<br />
Âge au 31 sept 2010:<br />
<input type="text" name="age" size="45" />
<br />
Date besoin de la place:(dd-mm-aaaa)<br />
<input type="text" name="dateplace" size="45" />
<br />
Besoin d'heures de garde:<br />
<input type="text" name="besoinheures" size="45" />
<br /><br />
Langue Parlée à la maison:<br />
<input type="text" name="langue" size="45" />
<br /><br />
Statut de la place:<br /><br />
Temps plein:<br />
<input type="radio" name="tempsplain" value="Oui">Oui
<input type="radio" name="tempsplain" value="Non">Non <br /><br />
Temps partiel (Seulement pour les enfants de 2 ans et plus):<br /><br />
<input type="radio" name="tempspartiel1" value="Oui">Oui
<input type="radio" name="tempspartiel1" value="Non">Non <br /><br />
Indiquer les jours de préference: <br /><br />
3 Jours ou 2 Jours:<br /><br />
<input type="checkbox" name="semaine[]" value="Lundi" /> Lundi<br />
<input type="checkbox" name="semaine[]" value="Mardi" /> Mardi <br />
<input type="checkbox" name="semaine[]" value="Mercredi" /> Mercredi <br />
<input type="checkbox" name="semaine[]" value="Jeudi" /> Jeudi <br />
<br /><br />
<img src="img/bineta.gif" width="24" height="17" border="0" />Formulaire pour:<br /><br />
Inscription ou Liste d'Attente :<br />
<input type="radio" name="inscrip" value="Inscription">Inscription
<input type="radio" name="inscrip" value="Liste d'Attente">Liste d'Attente <br /><br />
<br />
<br />
<br />
<img src="img/bineta.gif" width="24" height="17" border="0" />Coordonées du Parent Inscripteur:<br /><br />
Nom de Parent: <br />
<input type="text" name="parent" size="45" />
<br />
Adresse: <br />
<input type="text" name="adresse" size="45" />
<br />
Tel maison: <br />
<input type="text" name="tel" size="45" />
<br />
Portable: <br />
<input type="text" name="portable" size="45" />
<br />
Courriel: <br />
<input type="text" name="Email" size="45" />
<br />
Informations complémentaires:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br /><br />
<input type="submit" value="Soumettre" />
<br />
</form>







Sendail.php


<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$enfant = $_POST['enfant'];
$naissance = $_POST['naissance'];
$age = $_POST['age'];
$dateplace = $_POST['dateplace'];
$besoinheures = $_POST['besoinheures'];
$langue = $_POST['langue'];
$tempsplain = $_POST['tempsplain'];
$tempspartiel1 = $_POST['tempspartiel1'];
$semaine = $_POST['semaine'];
$parent = $_POST['parent'];
$adresse = $_POST['adresse'];
$tel = $_POST['tel'];
$portable = $_POST['portable'];
$Email = $_POST['Email'];
$notes = $_POST['notes'];
$inscrip = $_POST['inscrip'];
if(!$Email == "" && (!strstr($Email,"@") || !strstr($Email,".")))
{
echo "<h2>Utilisez Retour - Entrez e-mail valide</h2>\n";
$badinput = "<h2>Commentaires n'a pas ete presente</h2>\n";


echo $badinput;
die ("Retournez! ! ");
}

if(empty($enfant) || empty($naissance) || empty($age) || empty($dateplace) || empty($besoinheures) || empty($tempsplain) || empty($tempspartiel1) || empty($semaine) || empty($langue) || empty($adresse) || empty($parent) || empty($tel) || empty($portable) || empty($Email) || empty($notes )) {
echo "<h2>Utilisez Retour - remplir tous les champs</h2>\n";
die ("Utilisez Retour! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;

$inscrip = $inscrip ;
$subject = $inscrip;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Formulaire: $inscrip \n
Coordonées du Parent: $parent \n
Information Enfant: $enfant \n
Date de Naissance: $naissance \n
Age au 31 sept 2010: $age \n
Date besoin de la place: $dateplace \n
Besoin d'heures de garde: $besoinheures \n
Langue Parlée à la maison: $langue \n
Temps Plein: $tempsplain \n
Temps Partiel: $tempspartiel1 \n
3 Jours * 2 Jours: $semaine \n
Formulaire pour: $inscrip \n
Coordonées du Parent Inscripteur: $parent \n
Adresse: $adresse \n
Tel maison: $tel \n
Portable: $portable \n
Courriel: $Email \n
Additional Info : IP = $ip \n
Referral : $httpref \n
";

$from = "From: $Email\r\n";

mail("xxxxxxxxxx@gmail.com (xxxxxxxxxx@gmail.com)", $subject, $message, $from);

?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Merci! l'enregistrement est en cours : <?php echo $parent ?> ( <?php echo $enfant ?> )
<br />
Formulaire envoye: <?php echo $inscrip ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $inscrip);
echo $notesout; ?>
<br />
<?php echo $ip ?>
<br /><br />
<a href="index.html"> Accueil </a>
</p>

</body>

</html>

edbr
04-29-2011, 05:58 AM
easiest way if you add
$semaine = print_r ($semaine,true);
afte rdeclaring post values

$semaing willm showie 3 Jours * 2 Jours: Array ( [0] => Mercredi [1] => Jeudi )

claroquetengo
04-29-2011, 06:08 AM
Hi edbr, I dont know a lot about PHP., I got info on internet and I copy and paste... I put your answer on my php ...but I got a big error, Can you help me.....thx....
How and where I can to put your answer on my php....thx

edbr
04-29-2011, 06:25 AM
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$enfant = $_POST['enfant'];
$naissance = $_POST['naissance'];
$age = $_POST['age'];
$dateplace = $_POST['dateplace'];
$besoinheures = $_POST['besoinheures'];
$langue = $_POST['langue'];
$tempsplain = $_POST['tempsplain'];
$tempspartiel1 = $_POST['tempspartiel1'];
$semaine = $_POST['semaine'];
$parent = $_POST['parent'];
$adresse = $_POST['adresse'];
$tel = $_POST['tel'];
$portable = $_POST['portable'];
$Email = $_POST['Email'];
$notes = $_POST['notes'];
$inscrip = $_POST['inscrip'];




$semaine = print_r ($semaine,true);

should do it

claroquetengo
04-29-2011, 02:38 PM
edbr. Thanks for the quick response, thanks greatly for your help, I`m up and running! You`re great! but I wanna know if I can to got other answer different on my email. (cutest)
3 Jours * 2 Jours: Array
(
[0] => Lundi
[1] => Mercredi
[2] => Jeudi
)

edbr
04-30-2011, 01:02 AM
ok this is what you want i think


$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$enfant = $_POST['enfant'];
$naissance = $_POST['naissance'];
$age = $_POST['age'];
$dateplace = $_POST['dateplace'];
$besoinheures = $_POST['besoinheures'];
$langue = $_POST['langue'];
$tempsplain = $_POST['tempsplain'];
$tempspartiel1 = $_POST['tempspartiel1'];
$parent = $_POST['parent'];
$adresse = $_POST['adresse'];
$tel = $_POST['tel'];
$portable = $_POST['portable'];
$Email = $_POST['Email'];
$notes = $_POST['notes'];
$inscrip = $_POST['inscrip'];

foreach($_POST['semaine'] as $value) {
$checkbox .= "$value\n";
}

$semaine = $checkbox ;



$todayis = date("l, F j, Y, g:i a") ;

$inscrip = $inscrip ;
$subject = $inscrip;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Formulaire: $inscrip \n
Coordonées du Parent: $parent \n
Information Enfant: $enfant \n
Date de Naissance: $naissance \n
Age au 31 sept 2010: $age \n
Date besoin de la place: $dateplace \n
Besoin d'heures de garde: $besoinheures \n
Langue Parlée à la maison: $langue \n
Temps Plein: $tempsplain \n
Temps Partiel: $tempspartiel1 \n
3 Jours * 2 Jours: $semaine \n
Formulaire pour: $inscrip \n
Coordonées du Parent Inscripteur: $parent \n
Adresse: $adresse \n
Tel maison: $tel \n
Portable: $portable \n
Courriel: $Email \n
Additional Info : IP = $ip \n
Referral : $httpref \n
";

edbr
05-03-2011, 12:57 AM
claroquetengo i have removed the banned status from you and must apologise. to be quite honest i do not know how that happened ,i can only assume you were banned by mistake while doing a clearout of spammers ad somehow the post was included . once again my apologies

claroquetengo
01-29-2012, 08:02 PM
claroquetengo i have removed the banned status from you and must apologise. to be quite honest i do not know how that happened ,i can only assume you were banned by mistake while doing a clearout of spammers ad somehow the post was included . once again my apologies



Hi Friend, Do you remember me???

Hello,
I dont know about PHP, I`m taking a cours about that...but I`m really so stupid to do this...

I need help ...please :sad:


=================

*Page 1 (index):

First Page (index), the user must enter the total number of pages is printed.


Once the user clicks the button, the data input is transferred to a page (TraitementPage.php).

< html>
< head>
< title>Pages Imprimees </title>
< body>

< form action="TraitementPage.php" method="post" >
< br>
Nombre de page de votre documents : <input type="text" size="15" name="nomPages">
< br>
< br>
< input type="submit" value="Valider" />
< input type="reset" value="Annuler" />
< /form>
< /body>
< /head>
< /html>

===================

*Page 2 (TraitementPage.php) :

Validation Number of page:
* Confirm the presence of a value in the input field (From page index). In the event of an error, display a message "Please enter a value."
* Confirm the presence of a numeric value in the input field. In the event of an error, display an error message "Please enter a numeric value"

< ?php
$nomPages=$_POST["nomPages"];
if ($nomPages=="")
{echo "Champ Vide !!";}
elseif(is_numeric($nomPages)!=true)
{echo " Entrez une valeur numerique, Merci";}
else
{echo " <html><body><form action =\"OptionDimpression.php\" method=\"post\" enctype=\"multipart/form-data\">";


echo " <h2 align=\"center\">Service d'impression<h2>
< p align=\"center\">
< table border=\"1\">
< tbody><tr><td align=\"center\">
< br>Vous désirez imprimer :".$nomPages." Page(s) <br></td></tr>
< input type=\"hidden\" name=\"champ_cache\" value=\"nomPages\" />
< tr><td><input name=\"typeImpression\" value=\"All\" type=\"radio\" checked=\"checked\">
Toutes les pages<br></td></tr>
< tr><td><input name=\"typeImpression\" type=\"radio\" value=\"select\">
Pages
< input size=\"2\" id=\"pageDebut\" name=\"pageDebut\" type=\"text\">
à
< input size=\"2\" id=\"pageFin\" name=\"pageFin\" type=\"text\"></td></tr>
< tr><td align=\"center\">
< input value=\"Imprimer\" type=\"submit\"></td></tr>
< /tbody></table>
< br>
< /p>
< /form>
< /body>
< /html>";}
?>

==========================

I need help here ....3th Page


< ?php
$validation=$_POST["champ_cache"];
$choix=array();

if (isset($validation))


{
echo" Impression des pages : ".$choix."<br>";
}
{
echo"Nombre des pages imprimées : ".$validation;
}


?>

1- Method 1 (all pages):

If the user decides to view all pages and click on the PRINT button, it is directed to a third page (OptionDimpression.php) that displays the number of pages printed, the number of each page.

(example)
Printing pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Number of printed pages : 24

2- Method 2 (a range of pages):

If the user specifies a page range (the second radio button), you must do the following validations:
1. The page number of beginning can not be less than 1,
2. The page number at the end can not be greater than the total number of pages of the document,
3. The page number of beginning can not be greater than the page number at the end.
- In case any of the previous validation does not show you the user an error message.


Printing pages: 12 13 14 15 (rand)
Number of printed pages: 4


HELP ME PLEASE....:razz:

Thx