Bonjour a vous,
je suis un débutant en php, j'ai crée une formulaire d'enregistrement et et un code php pour insertion des données dans la base de donnée.
mon code n'a pas d'erreur, mais aucun enregistrement ne se produit dans ma base de donée.
voici mon code: html + php
envoyer.phpht.phpenvoyer.phpht.php
code php:
<?php
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$sexe = $_POST['sexe'];
$situation = $_POST['situation'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$specialite = $_POST['specialite'];
$formation = $_POST['formation'];
$etude= $_POST['etude'];
$emploi = $_POST['emploi'];
$salaire = $_POST['salaire'];
$mobilite = $_POST['mobilite'];
if($nom&&$prenom&&$sexe&&$situation&&$telephone&&$email&&$specialite&&$formation&&$etude&&$emploi){
if(empty($_POST['nom']))
{
$bd->query("SET NAMES UTF8");
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bd = new PDO('mysql:host=localhost;dbname=travail; charset=UTF8', 'root', '', $pdo_options);
$query =$bd->prepare('INSERT INTO emploi(nom, prenom, sexe, situationfamiliale, telephone, email, specialite, formationprincipale, niveauetude, typecandidature, pretentionsalarialesalaire, disponibilite, mobilite) VALUES(:nom, :prenom, :sexe, :situation, :telephone,:email, :specialite, :formation :etude, :emploi, :salaire, :mobilite)');
$query->execute(array(
'nom' => $nom,
'prenom' => $prenom,
'sexe' => $sexe,
'situationfamiliale' => $situation,
'telephone' => $telephone,
'email' => $email,
'specialite' => $specialite,
'formationprincipale' => $formation,
'niveauetude' => $etude,
'typecandidature' => $emploi,
'pretentionsalariale' => $salaire,
'mobilite' => $mobilite,
))
or die ( print_r($req->errorInfo()) );
}die ("VOTRE CANDIDATURE A BIEN ETE PRIS EN COMPTE");
}else echo "Veuillez renseigner tous les champs";
?>
code html :
<html>
<head> <title> ma candidature </title> </head>
<body>
<form method="post" name="form1" action="envoyer.php">
<table align="center" width="100%">
<tr valign="baseline">
<td height="48" colspan="2" align="center" valign="middle" nowrap="nowrap" bgcolor="#00CCFF"><span style="color:#FFF;font-size:14px"><strong>Votre état civil</strong></span></td>
</tr>
<tr valign="baseline">
<td width="100" align="right" nowrap="nowrap">Nom:</td>
<td>
<input type="text" name="nom" value="" size="32" />
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Prenom:</td>
<td>
<input type="text" name="prenom" value="" size="32" />
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Sexe:</td>
<td valign="middle"> <input type="texte" name="sexe" value="" size="32" />
homme ou femme <p> </p>
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Situation familiale:</td>
<td><input type="texte" name="situation" value=" " size="32" />
</BR> marié, celibataire ou divorcé<p> </p>
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Téléphone:</td>
<td><span id="sprytextfield3">
<input type="text" name="telephone" value="" size="20" />
</span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Adresse mail:</td>
<td><span id="sprytextfield4">
<input type="mail" name="email" value="" size="32" />
</span></td>
</tr>
<tr valign="baseline">
<td colspan="2" align="left" nowrap="nowrap"> </td>
</tr>
<tr valign="baseline">
<td height="48" colspan="2" align="center" valign="middle" nowrap="nowrap" bgcolor="#00CCFF"><span style="color:#FFF;font-size:14px"><em>Votre formation</em></span></td>
</tr>
<tr valign="baseline">
<td height="41" align="right" valign="top" nowrap="nowrap"> Specialité:</td>
<td valign="baseline"> <input type="texte" name="specialite" value="" size="32" />
</BR> le domaine dans le quelle vous éxercez <p> </P> </td>
</tr>
<tr valign="baseline">
<td height="37" align="right" nowrap="nowrap">Formation principale:</td>
<td valign="baseline"> <input type="text" name="formation" value="" size="32" />
</BR>
filiére etudié à l'ecole <p> </p>
</td>
</tr>
<tr valign="baseline">
<td height="43" align="right" nowrap="nowrap">Niveau d'étude:</td>
<td valign="baseline"> <input type="text", name="etude" value="" size="32" />
</BR>
bac, bac+1, bac+2,+3, bac+4 ou plus <P> </p>
</td>
</tr>
<tr valign="baseline">
<td align="right" nowrap="nowrap">Type de candidature:</td>
<td valign="baseline"><input type="text" name="emploi" value="" size="32" />
</BR> stage, spontanée, ou offre de recrutement
<p> </P>
</td>
</tr>
<tr valign="baseline">
<td height="23" colspan="2" align="left" valign="middle" nowrap="nowrap"> </td>
</tr>
<tr valign="baseline">
<td height="58" colspan="2" align="center" valign="middle" nowrap="nowrap" bgcolor="#00CCFF"><h1><span style="color:#FFF;font-size:14px"><em>Informations supplémentaires</em></span></h1></td>
</tr>
<tr valign="baseline">
<td height="39" align="right" valign="top" nowrap="nowrap">Prétention salariale:</td>
<td align="left" nowrap="nowrap"><label for="salaire"></label>
<span id="sprytextfield6">
<input name="salaire" type="text" id="salaire" size="10" maxlength="10" />
</span></td>
</tr>
<tr valign="baseline">
<td height="40" align="right" valign="top" nowrap="nowrap">Mobilité:</td>
<td align="left" nowrap="nowrap"><label for="mobilite"></label>
<input type="text" name="mobilite" value="" size="32" />
</BR>
locale,regionale,nationale,ou internationale <p> </p>
</td>
</tr>
<tr valign="baseline">
<td colspan="2" align="left" nowrap="nowrap">
<tr>
<td height="43">
<div class="g-recaptcha" data-sitekey="6LeAqhMTAAAAAKczyaAUrevsgTi7mBrdKWhWdSPy"></div>
</td>
</tr>
<tr valign="baseline">
<td colspan="2" align="left" nowrap="nowrap"><p>
<input type="submit" value="Envoyer votre candidature" />
</p>
<p> </p></td>
</tr>
</table>
<input name="dateDepot" type="hidden" value="2017-07-24 12:11:07" />
<input name="nbrExp" type="hidden" id="nbrExp" value="0" />
<input type="hidden" name="idCandidat" value="AUTO24072017121107" />
</form>
</body>
</html>
Partager