PROBLEME RECUPERATION DONNEES FORMULAIRE PHP

Résolu/Fermé
lolopoune Messages postés 1 Date d'inscription samedi 13 décembre 2008 Statut Membre Dernière intervention 11 février 2009 - 11 févr. 2009 à 23:40
 lolopoune - 12 févr. 2009 à 10:19
Bonjour,

Je viens de créer un formulaire afin de récolter des informations (1) ainsi qu'un formulaire de récupération de données (2). Lorsque je reçois le formulaire de récupération par email, les champs des données sont vides alors le formulaire a été correctement renseignement. Voici ce que je reçois ainsi que les scripts des formulaires, l'un de vous peut-il mâider ?

Sex=
Type=
Nom=
Prenom=
Adresse=
Npa=
Localite=
Pays=
Telephone=
Fax=
PA phone=
Organization=
Flight=
Airline=
Choix hotel1=
Date darrivee=
Mois darrivee=
Date de depart=
Mois de depart=
Carte de credit=
CVC=
Mois d expiration=
Annee d expiration=
Comment=
Adresse email :
___________________________________
Formulaire 1
___________________________________

<!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>
<title>Booking form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="JavaScript">
//La fonction JavaScript qui vérifie si les champs obligatoirs du formulaire ont été bien remplis
<!--
function envoi(formulaire) {
if ( (document.getElementById('name').value.length>0)
&&(document.getElementById('firstname').value.length>0)
&&(document.getElementById('address').value.length>0)
&&(document.getElementById('npa').value.length>0)
&&(document.getElementById('city').value.length>0)
&&(document.getElementById('country').value.length>0)
&&(document.getElementById('phone').value.length>0)
&&(document.getElementById('country').value.length>0)
&&(document.getElementById('email').value.length>0)
){
formulaire.submit();
} else
alert('IMPOSSIBLE TO SEND YOUR REQUEST, YOU FORGOT TO FILL SOME MANDATORY FIELD');
}
-->
</script>
<style type="text/css">
<!--
.Style13 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: small;
}
body {
background-color: #CCCCCC;
}
.Style20 {color: #FFFFFF; font-weight: bold;}
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.Style29 {color: #FFFFFF}
.Style129 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: medium;
color: #990000;
font-weight: bold;
}
.Style132 {font-weight: bold}
.Style134 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; font-weight: bold; }
.Style136 {
font-size: small
}
.Style138 {color: #FFFFFF; font-size: small; }
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.Style146 {
font-size: medium;
color: #990000;
font-weight: bold;
}
.Style147 {
color: #990000
}
.Style149 {
font-size: small;
font-weight: bold;
color: #FFFFFF;
}
.Style150 {color: #000000}
-->
</style>
</head>

<body>
<div align="center">
<blockquote>
<table width="826" border="2" cellspacing="1" cellpadding="1" bgcolor="#990000">
<caption>
</caption>

<tr>
<td width="816"><table width="814" border="1" cellspacing="1" cellpadding="1">
<tr>
<td colspan="4" class="Style132"><div align="center" class="Style29"><span class="Style13"> Mr
<input type="radio" name="sex" value="Mr"id="sexmrs2" />
   Mrs
<input type="radio" name="sex" value="Mrs"id="sexms2" />
   Ms
<input type="radio" name="sex" value="Ms"id="sexdr2" />
   Dr
<input type="radio" name="sex" value="Dr"id="sexprof2" />
   Prof.
<input type="radio" name="sex" value="Prof"id="sex" />
  </span><span class="Style136">Other title</span> <span class="Style13">
<input type="text" name="title"id="title" />
</span></div></td>
</tr>
<tr>
<td colspan="2" class="Style138">Type of participant :</td>
<td colspan="2" class="Style29"><div align="center"><span class="Style13">guest
<input type="radio" name="type" value="guest"id="guest" />
    speaker
<input type="radio" name="type" value="speaker"id="speaker" />
   accompanying person
<input type="radio" name="type" value="accomp"id="accomp" />
</span></div></td>
</tr>
<tr>
<td width="148" class="Style29"><span class="Style13">Family name :</span></td>
<td width="226" class="Style29"><span class="Style13">
<input type="text" name="name" id="name" />
</span></td>
<td width="195" class="Style29"><span class="Style13">First name : </span></td>
<td width="222" class="Style29"><span class="Style13">
<input type="text" name="firstname"id="firstname" />
</span></td>
</tr>
<tr>
<td class="Style29"><span class="Style13">Address :</span></td>
<td class="Style29"><span class="Style13">
<input type="text" name="address"id="address" />
</span></td>
<td class="Style29"><span class="Style13">Zip Code : </span></td>
<td class="Style29"><span class="Style13">
<input name="npa" type="text" id="npa"/>
</span></td>
</tr>
<tr>
<td class="Style29"><span class="Style13">City : </span></td>
<td class="Style29"><span class="Style13">
<input name="city" type="text" id="city" />
</span></td>
<td class="Style29"><span class="Style13">Country : </span></td>
<td class="Style29"><span class="Style13">
<input name="country" type="text" id="country" />
</span></td>
</tr>
<tr>
<td class="Style29"><span class="Style13">Phone number : </span></td>
<td class="Style29"><span class="Style13">
<input name="phone" type="text" id="phone" />
</span></td>
<td class="Style29"><span class="Style13">Fax number :</span></td>
<td class="Style29"><span class="Style13">
<input name="fax" type="text" id="fax" />
</span></td>
</tr>
<tr>
<td class="Style29"><span class="Style138">Mobile phone :</span></td>
<td class="Style29"><span class="Style13">
<input name="mobile" type="text" id="mobile" />
</span></td>
<td class="Style29"><span class="Style13">Organization : </span></td>
<td class="Style29"><span class="Style13">
<input name="organization" type="text" id="organization" />
</span></td>
</tr>
<tr>
<td height="26" colspan="2"><p align="right" class="Style138"><span class="Style13">Personal Assistant's name and phone number :</span></p></td>
<td colspan="2"><span class="Style29"><span class="Style13">
<input name="paphone" type="text" id="paphone" maxlength="200" />
</span></span></td>
</tr>
<tr>
<td colspan="4" class="Style29"><div align="left">
<p align="center"><span class="Style13">Select your accommodation at KA Foundation special rates :
<select name="hotel1" id="hotel1">
<option value='Classic Room CHF 360.- per night'>Classic Room Intercontinental Hotel CHF 360.- per night</option>
<option value='Superior Room CHF 395.- per night'>Superior Room Intercontinental Hotel CHF 395.- per night</option>
<option value='Ambassador Suite CHF 490.- per night'>Ambassador Suite Intercontinental Hotel CHF 490.- per night</option>
<option value='Lake Geneva Suite CHF 590.- per night'>Lake Geneva Suite Intercontinental Hotel CHF 590.- per night</option>
<option value='Executive Suite CHF 790.- per night'>Executive Suite Intercontinental Hotel CHF 790.- per night</option>
<option value='Standard Room Drake Hotel CHF 155.- per night'>Standard Room Drake Hotel CHF 155.- per night</option>
</select>
</span></p>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center" class="Style29">
<div align="left"><span class="Style13">Arrival date :
<input name="arrD2" type="text" size="2" maxlength="2" value="" />
/
<input name="arrM2" type="text" size="2" maxlength="2" value="" />
/
<input name="arrY2" type="text" size="5" maxlength="4" value="" />
(DD/MM/YYYY) </span></div>
</div></td>
<td colspan="2" ><div align="center" class="Style29">
<div align="left"><span class="Style13">Departure date :
<input name="arrD3" type="text" size="2" maxlength="2" value="" />
/
<input name="arrM3" type="text" size="2" maxlength="2" value="" />
/
<input name="arrY3" type="text" size="5" maxlength="4" value="" />
(DD/MM/YYYY) </span></div>
</div></td>
</tr>
<tr>
<td colspan="4" "><div align="center" class="Style29"><span class="Style13">Room type :
<input name="room" type="radio" value="single" />
Single     
<input name="room" type="radio" value="double" />
Double Bed     
<input name="room" type="radio" value="twin" />
Twin Beds     
<input name="smoke" type="radio" value="no" />
Non-Smoking     
<input name="smoke" type="radio" value="yes" />
Smoking</span></div></td>
</tr>
<tr>
<td colspan="4"><div align="center">
<p class="Style29"><span class="Style134">Please provide additional information below to guarantee your hotel booking * </span></p>
</div></td>
</tr>
<tr>
<td colspan="4" class="Style132"><div align="center" class="Style29"><span class="Style13">Type :
<input name="cType" type="radio" value="visa" />
Visa  
<input name="cType" type="radio" value="ecmc" />
MasterCard  
<input name="cType" type="radio" value="amex" />
Amex  
<input name="cType" type="radio" value="dinr" />
Diners </span></div></td>
</tr>
<tr>
<td colspan="4" ><div align="center" class="Style29"><span class="Style13"><strong>Card Number :</strong>
<input name="ccnumber" type="text" size="36" maxlength="16" value="" id="ccnumber" />
</span></div></td>
</tr>
<tr>
<td class="Style132"><div align="right" class="Style29"><span class="Style13">Name on Card :</span> </div></td>
<td class="Style29"><span class="Style13">
<input name="ccName" type="text" size="36" maxlength="64" value="" id="ccName" />
</span></td>
<td class="Style132"><div align="right" class="Style29"><span class="Style13">Exp.Date : </span></div></td>
<td class="Style29"><span class="Style13">
<input name="ccmonth" type="text" size="2" maxlength="2" value="" id="ccmonth" />
/
<input name="ccyear" type="text" size="2" maxlength="2" value="" id="ccyear" />
</span></td>
</tr>
<tr>
<td colspan="4" class="Style132"><div align="center" class="Style29"><span class="Style13">CCV Number :
<input name="CCCV" type="text" size="2" maxlength="4" value="" id="comment"/>
Last three digits on the back (or front for Amex) of the card if available </span></div></td>
</tr>
<tr></tr>
</table></td>
</tr>
<tr>
<td height="182"><p align="center" class="Style20"><span class="Style13">*No fees up to 48 hours prior arrival - 1 Night charged for any cancellation made less than 48 hours prior to arrival.</span></p>
<p align="center" class="Style29"><span class="Style134">Comments :
<textarea name="comment" cols="80" rows="4"></textarea>
</span></p>
<blockquote>
<blockquote>
<blockquote>
<p align="center"><span class="Style134"><span class="Style29"> E-mail address :</span></span><span class="Style13">
<input name="email" type="text" size="36" maxlength="100" value="" id="email" />
</span> </p>
</blockquote>
</blockquote>
</blockquote>
<div align="center"><span class="Style149">A copy of your national passport is mandatory for authorities and visa procedure. </span></div></td>
</tr>
</table>
</blockquote>
</div>
<form action="/envoi.php" method="post" name="form_contacts" id="form_contacts">
<blockquote><p align="center"><strong>
<span class="Style13">
<input name="Send" type="submit" class="Style132" id="envoyer" onclick="envoi(this.form)" value="Send" />
<input name="clear all" type="reset" class="Style132" id="clear all" value="Clear all" />
</span>
<input name="print" type="button" class="Style132" id="print" onclick="window.print();" value="Print" />
<span class="Style147"><span class="Style147">Print our </span><a href="/form.pdf" target="_blank">PDF version</a></span></strong></p>
</blockquote>
</form>
</body>
</html>

______________________________________________________________

formulaire 2 - recup de données
______________________________________________________________


<!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" />
<title>Many thanks</title>

<?php
//On récupère les valeurs du formulaire
$type = $_POST['type'];
$sex = $_POST['sex'];
$name = $_POST['name'];
$prenom = $_POST['firstname'];
$adresse = $_POST['address'];
$npa = $_POST['npa'];
$localite = $_POST['city'];
$Pays = $_POST['country'];
$tel = $_POST['tel'];
$paphone = $_POST['paphone'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$hotel1 = $_POST['hotel1'];
$arrD2 = $_POST['arrD2'];
$arrM2 = $_POST['arrM2'];
$arrY2 = $_POST['arrY2'];
$arrD3 = $_POST['arrD3'];
$arrM3 = $_POST['arrM3'];
$arrY3 = $_POST['arrY3'];
$room = $_POST['room'];
$smoke = $_POST['smoke'];
$cType = $_POST['cType'];
$ccnumber = $_POST['ccnumber'];
$ccname = $_POST['ccname'];
$ccmonth = $_POST['ccmonth'];
$ccyear = $_POST['ccyear'];
$CCCV = $_POST['CCCV'];
$comment = $_POST['comment'];


?>
<?php //On créée le message email
$msg = "Sex= $sex
Type= $type
Nom= $name
Prenom= $firstname
Adresse= $address
Npa= $npa
Localite= $city
Pays= $country
Telephone= $mobile
Fax= $fax
PA phone= $paphone
Organization= $organization
Flight= $flight
Airline= $airline
Choix hotel1= $hotel1
Date darrivee= $arrD2
Mois darrivee= $arrM2
Date de depart= $arrD3
Mois de depart= $arrM3
Carte de credit= $ccnumber
CVC= $CCVC
Mois d expiration= $ccmonth
Annee d expiration= $ccyear
Comment= $comment
Adresse email : $email";

$recipient = "xx@gmail.com"; //On met l'adresse email ou on veut recevoire le mail
$subject = "Booking Form"; //On met le sujet du mail
mail($recipient, $subject, $msg, $mailheaders); // message confirmation que le mail a bien été envoyé

echo "<HTML><HEAD>";
echo "<TITLE>Your form has been sent !</TITLE></HEAD><BODY>";
echo "<H1 align=center>Thank you, $sex $nom </H1>";
echo "<P align=center>";
echo "Your form has been sent !</P>";
echo "</BODY></HTML>";

?>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style></head>
<body>
</body>
</html>
A voir également:

4 réponses

bissdebrazza Messages postés 2065 Date d'inscription vendredi 29 juin 2007 Statut Contributeur Dernière intervention 7 décembre 2017 712
12 févr. 2009 à 00:28
Salut!
Je crois que tu devais mettre ton formulaire au début,et non à la fin de ta page.C'est-à-dire après le body, tu met tout dans le form (nom,prenom,sexe.....)tu comprends?
0
974_Vin's_974 Messages postés 547 Date d'inscription vendredi 23 janvier 2009 Statut Membre Dernière intervention 19 février 2009 102
12 févr. 2009 à 05:59
Mets ton formulaire entre les balise <body> .. </body>

0
niahoo Messages postés 247 Date d'inscription lundi 24 décembre 2007 Statut Membre Dernière intervention 23 mai 2010 19
12 févr. 2009 à 09:45
oui bon en gros les donneés sont envoyées via les imput selon ce schéma:

<form action, method>
   <input type, name, value>
   <input type, name, value>
   <input type, name, value>
   <input type, name, value>
   <input type, name, value>
</form>


mais toi tu as ça:



   <input type, name, value>
   <input type, name, value>
   <input type, name, value>
   <input type, name, value>
   <input type, name, value>
<form action, method>
   <input type, name, value> 
</form>


En gros y a que te deux derniers imput se trouvent entre les balises form qui sont envoyées.

sur ta page php censée traiter le formulaire, je te conseille temporairement de tout enlever, (en le sauvegardant bien sur ) et de mettre ça:
<?php
print_r($_POST);
?>


ça va t'afficher tout ce qui à été envoyé sur la page par formulaire, et tu verra que tous tes champs Sex, Type, Name etc.. n'y figurent pas.
0
merci à vous c'est très gentil.
Niahoo, je vais changé mon script selon tes conseils :)
mille mercis et bonne journée,

laurence
0
niahoo Messages postés 247 Date d'inscription lundi 24 décembre 2007 Statut Membre Dernière intervention 23 mai 2010 19
12 févr. 2009 à 10:16
bonne chance, tu as juste a déplacer ta balise <form ... ... ..>
0
merci beaucoup et bonne journée,
:)
0