Bonjour je dois créer un site web qui gère les absences des employés dans une entreprise !!
Je souhaite donc que l'administrateur puisse ajouter une absence à un employé en précisant si c'est une absence justifié ou une non justifié.
J'ai donc créé une table qui contient tous les employés et dans cette table j'ai créé un champ absence justifié et un champ absence non justifié.
Je souhaite donc que lorsque l'administrateur ajoute une absence pour un employé, que le champ de l'absence correspondante soit incrémenté automatiquement.
J'ai donc écrit le script suivant mais celui-ci ne marche pas.
Voici le script du formulaire d'ajout d'une absence :
<?$bdd="université";
$host="localhost";
$user="root";
$pass="";
mysql_connect($host,$user,$pass) or die ("Impossible de se connecter à la base de données");
mysql_select_db($bdd);?>
<form action="ajout_absence_table.php" method='post'>
<p align="center"><font size="3" face="Verdana" color="#697291">Choisissez l'élève :</p></font>
<select name="nom" align="center">
<option value='-' ></option>
<?
$requet2="select * from tbl_user_admin";
if($result2=mysql_query($requet2))
{
while($ligne2=mysql_fetch_array($result2))
{
?><option value="<?echo $ligne2['nom'];?>">
<?echo $ligne2['nom'];
}
}
?>
</select>
<table align="center">
<tr>
<td><p align="center"><font size="3" face="Verdana" color="#697291">Type de l'absence :</p></font></td> </tr> <br><br>
<tr><td><select name="absence" align="center"><option value="-"></option>
<option value="1">Absence justifié
<option value="2">Absence non justifié
</select>
</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Envoyer"></td>
</tr>
</table>
voici le script qui devrait permettre d'incrémenter les champs absences mais qui ne marche pas pour l'instant :
<HTML>
<HEAD>
<TITLE>Bienvenue sur la page d'inscription de l'université de Pitesti</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta name="design">
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<p align="center"><TABLE WIDTH=777 BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
<TR>
<TD colspan=2>
<IMG SRC="images/index_01.jpg" WIDTH=248 HEIGHT=167 ALT=""></TD>
<TD COLSPAN=2>
<IMG SRC="images/index_02.jpg" WIDTH=392 HEIGHT=167 ALT=""></TD>
<TD>
<b><IMG SRC="images/index_03.jpg" WIDTH=137 BORDER=0 HEIGHT=167 ALT="" usemap="#ImageMap1"></b></TD>
</TR>
<TR>
<TD COLSPAN=2>
<IMG SRC="images/index_04.jpg" WIDTH=248 HEIGHT=20 ALT=""></TD>
<TD COLSPAN=3 height="20" background="images/index_05.jpg">
<p align="left"><span style="font-size:9pt;"><font face="Tahoma"> </font><font face="Tahoma" color="#7B8197">
</font><font face="Tahoma" color="#697291"> <a href="Accueil  '>http://127.0.0.1/projet/kit51/index.html">Accueil</a> |
<a href="Présentation  '>http://127.0.0.1/projet/kit51/presentation2.php">Présentation</a>
| <a href="Photos  '>http://127.0.0.1/projet/kit51/galerie-photos.php">Photos</a> |
<a href="Historique  '>http://127.0.0.1/projet/kit51/historique2.php">Historique</a> | <a href="Inscription'>http://127.0.0.1/projet/kit51/formulaire.php">Inscription </a>
</font></span></TD>
</TR>
<TR>
<TD COLSPAN=5>
<IMG SRC="images/index_06.jpg" WIDTH=777 HEIGHT=12 ALT=""></TD>
</TR>
<TR>
<TD bgcolor="whitesmoke">
<table align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="228" style="border-bottom-width:1; border-bottom-color:rgb(147,148,150); border-bottom-style:dashed;">
<p align="left"><b><font color="black" face="Verdana" size="1"> </font><font color="#697291" face="Verdana" size="1">
Université de Pitesti</font></b></p>
</td>
</tr>
<tr>
<td width="228">
<p><br><span style="font-size:8pt;"><font face="Verdana" color="#697291"><img src="C:\Documents and Settings\thibaud\Bureau\projet roumanie\photos\CIMG3390BIS.jpg">
<br><br><br></font></span></p>
</td>
</tr>
<tr>
<td width="228" style="border-bottom-width:1; border-bottom-color:rgb(147,148,150); border-bottom-style:dashed;"> <p align="left"><b><font color="black" face="Verdana" size="1"> </font><font color="#697291" face="Verdana" size="1">Zone
Membres</font></b></p>
</td>
</tr>
<tr>
<td width="228"> <form action="login.php" method='post'>
<p align="center">
<font face="Verdana" color="#697291" size="1"><b><br>Numéro étudiant :</font><br>
<input type="text" name="etude" style="border-width:1; border-color:rgb(147,148,150); border-style:solid;"><br>
<font face="Verdana" color="#697291" size="1"><b><br>Login :</font><br>
<input type="text" name="login" style="border-width:1; border-color:rgb(147,148,150); border-style:solid;"><br>
<font face="Verdana" color="#697291" size="1"><b><br>Mot de Passe :</b></font>
<font color="#697291" size="1" face="Verdana"><br> <input type="password" name="pass" style="border-width:1;
border-color:rgb(147,148,150); border-style:solid;"><br></font></p>
<p align="center"><font color="#697291" size="1" face="Verdana"><input type="submit" name="Envoyer" style="color:rgb(105,114,145); background-color:white; border-width:1; border-color:rgb(147,148,150); border-style:solid;">
<br> </font></p>
</form>
</td>
</tr>
<tr>
<td width="228" style="border-bottom-width:1; border-bottom-color:rgb(147,148,150); border-bottom-style:dashed;">
<p align="left"><b><font color="#697291" face="Verdana" size="1"> Nos
partenaires</font></b></p>
</td>
</tr>
<tr>
<td width="228">
<p><br> <font face="Verdana" size="1" color="#697291"> <a href="
[ Lien ]
http://www.upit.ro/">http://www.upit.ro/</a></font><br> <font face="Verdana" size="1" color="#697291"> <a href="
[ Lien ]
http://www.primariapitesti.ro/">http://www.primariapitesti.ro/</a><br></font> <font face="Verdana" size="1" color="#697291"> <a href="
[ Lien ]
http://www.romania.org/">http://www.romania.org/</a><br></font> <font face="Verdana" size="1" color="#697291"> <a href="
[ Lien ]
http://arges.einformatii.ro/">http://arges.einformatii.ro/</a></font><br></p>
</td>
</tr>
</table>
</TD>
<TD COLSPAN=2 background="images/index_08.jpg">
</TD>
<TD COLSPAN=2>
<?php
$bdd="université";
$host="localhost";
$user="root";
$pass="";
mysql_connect($host,$user,$pass) or die ("Impossible de se connecter à la base de données");
mysql_select_db($bdd);
// On commence par récupérer les champs
if(isset($_POST['absence'])) $absence=$_POST['absence'];
else $absence="";
if(isset($_POST['nom'])) $nom=$_POST['nom'];
else $nom="";
$query="SELECT abs_justifie,abs_non_justifie FROM tbl_user_admin WHERE nom='$nom'";
$result=mysql_query($query);
$tabResult=mysql_fetch_array($result);
if(empty($nom) OR empty($absence))
{
echo '<font color="red">Attention, aucun champ ne peut rester vide !</font>';
}
// Aucun champ n'est vide, on peut enregistrer dans la table
else
{
// connexion à la base
$db = mysql_connect('localhost', 'root', '') or die('Erreur de connexion '.mysql_error());
// sélection de la base
mysql_select_db('université',$db) or die('Erreur de selection '.mysql_error());
// on écrit la requête sql
if(($tabResult['abs_justifie'])||($tabResult['abs_non_justifie'])!=0)
{
if($absence==1)
{
$absence=$tabResult['abs_justifie']+1;
$sql = "INSERT INTO tbl_user_admin(abs_justifie) VALUE('$absence')";
}
else
{
$absence=$tabResult['abs_non_justifie']+1;
$sql = "INSERT INTO tbl_user_admin(abs_non_justifie) VALUE('$absence')";
}
// on insère les informations du formulaire dans la table
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
// on affiche le résultat pour le visiteur
echo 'Vos infos on été ajoutées.';
mysql_close(); // on ferme la connexion
}
else
{
$sql = "INSERT INTO tbl_user_admin(abs_justifie) VALUES('$absence')";
}
}
?>
<br><br></font></span></P></TD>
</TR>
<TR>
<TD height="28" background="images/index_10.jpg">
<p align="center"> </TD>
<TD COLSPAN=4 background="images/index_11.jpg">
<p align="center"><font size="1" face="Verdana" color="#697291"> </font><FONT face="Verdana,Helvetica" size="1" color="#697291">
Site de l'université de Pitesti - Tous droits Réservés</FONT></p>
</TD>
</TR>
<TR>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=238 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=10 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=9 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=383 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=137 HEIGHT=1 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
Sivous voyez d'où vient l'erreur merci de m'en informer
merci d'avance pour vos réponses.