Bonjour et meilleurs voeux à toutes et à tous pour 2009,
J'aimerai savoir si il est possible dans un même script de faire une saisie d'un formulaire et à la validation, insérer la fiche dans la BDD.
Pour comprendre mieux voila le script :
<html>
<head>
<title>I.R.P USL-SO</title>
</head>
<body>
<center><h1>SAISIE DES HEURES</h1></center>
<br><br>
<?php
include ('connection.inc.php');
$cnn=connection();
if (isset($_POST['$code']))
{
echo "<br><br><br> j'ai deja saisie le code " . $code . "je peux donc faire mon INSERT dans Mysql";
$code_abscence=$_POST["code"];
$nbre_heures = $_POST["nbre_heures"];
$mandat = $_POST["mandat"];
$date = $_POST["annee"] . $_POST["mois"] . $_POST["jour"];
$sql = "INSERT INTO heures_effectuees (code_abscence,nbre_heures,mandat,date) VALUE ('$code_abscence','$nbre_heures','$mandat','$date'";
$rs = mysql_query($sql,$cnn);
}
else
{
echo "<form name=\"formulaire\" method=\"post\" action=\"saisie_heures.php\">";
echo "Code Abscence : ";
$sql="SELECT * FROM code_abscence ORDER BY code";
$rs=mysql_query($sql,$cnn);
echo "<select name=\"code\">";
while ($ligne=mysql_fetch_array($rs,MYSQL_ASSOC))
{ $code=$ligne['code'];
$theme_suivi=$ligne['theme_suivi'];
echo "<option>" . $code . " " . $theme_suivi;
}
echo "</select><br><br>";
echo "Nombre d'heures :";
echo "<select name=\"nbre_heures\">";
for ($heure=0;$heure<1000;$heure++)
{$ligne = "<option>";
echo $ligne . $heure;}
echo "</select><br><br>";
echo "Mandat concerné :";
$sql="SELECT * FROM mandat_agent ORDER BY agent_mandat";
$rs=mysql_query($sql,$cnn);
echo "<select name=\"mandat\">";
while ($ligne=mysql_fetch_array($rs,MYSQL_ASSOC))
{ $agent_mandat=$ligne['agent_mandat'];
echo "<option>" . $agent_mandat ;
}
echo "</select><br><br>";
echo "Date du détachement :";
echo "<select name=\jour\">";
for ($jour=01;$jour<32;$jour++)
{ echo "<option>" . $jour;}
echo "</select> ";
echo "<select name=\"mois\">";
for ($mois=01;$mois<13;$mois++)
{ echo "<option>" . $mois ; }
echo "</select> ";
echo "<select name=\"annee\">";
echo "<option>2008 <option>2009 <option>2010";
echo "</select>";
echo "<br><br>";
echo "<br><br> <input value=\"Valider\" type=\"SUBMIT\" > <input value=\"Effacer\" type=\"RESET\" > </form>";
}
?>
</body>
</html>
Si cela n'est pas possible alors je referai comme avant avec 2 scripts.
Merci.
Patrick