function agentDelete($num) {
mysql_query("delete from agent_dentretien where num_pers = '$num'");
mysql_query("delete from contrat_travail where num_pers1 = '$num'");
mysql_query("delete from information where num_pers1 = '$num'");
mysql_query("delete from absence where num_pers = '$num'");
}
dans mon fichier agtentDel.php
<?php
include_once("../connexion.php");
include_once("../fonction.inc.php");
if (isset($_GET['id']))
$mat = $_GET['id'];
else
$mat = "";
agentDelete($mat) ;
header("Location: consult_agtent.php");
?> <a href='agtentDel.php' id="<?php echo $mat ?>" onClick="return conf()">suppr</a>
voila, peut etre que vous comprendriez mieux<a href='agtentDel.php' id="<?php echo $mat ?>" onClick="return conf()">suppr</a> Ici $_GET['id'] ne sera pas défini<a href="agtentDel.php?id=<?php echo $mat ?>" onClick="return conf()">suppr</a> Ici $_GET['id'] sera égal au $mat
<?php
function agentDelete($num) {
mysql_query("delete from agent_dentretien where num_pers = '$num'");
mysql_query("delete from contrat_travail where num_pers1 = '$num'");
mysql_query("delete from information where num_pers1 = '$num'");
mysql_query("delete from absence where num_pers = '$num'");
}
?>
function validate(enreg) {
val1 = document.enreg.nom.value;
while('' + val1.charAt(0)==' ')
val1 = val1.substring(1, val1.length);
if (val1 == "") {
alert("Veuillez saisir le nom de l'agent d'entretien.");
document.enreg.nom.focus();
return false;
}
}
le form :<form name="enreg" onSubmit="return validate(this)" method="post" action="agtentAdd.php">
le bouton :
<input name="enreg" type="submit" id="enreg" value="sauvegarde">
le fenetre agtentAdd.php :
<?php
include_once("../connexion.php");
include_once("../fonction.inc.php");
if (isset($HTTP_POST_VARS["nom"]))
$nom = $HTTP_POST_VARS["nom"];
else
$nom = "";
if (isset($HTTP_POST_VARS["nat"]))
$nation = $HTTP_POST_VARS["nat"];
else
$nation = "";
agententAdd($nom, $nation);
header("Location: rech_agtent.php");
?>
et ma fonction :
function agententAdd($nom,$nation) {
mysql_query("insert into agent_dentretien(num_pers, nom_pers, nationalite) values('', '$nom', '$nation')");
}
A tout hasard...dans ta page fonction.inc.php, as-tu bien mis ta fonction entre les balise <?php et ?> ?
<?php function agentDelete($num) { mysql_query("delete from agent_dentretien where num_pers = '$num'"); mysql_query("delete from contrat_travail where num_pers1 = '$num'"); mysql_query("delete from information where num_pers1 = '$num'"); mysql_query("delete from absence where num_pers = '$num'"); } ?>
<?php
include_once("../connexion.php");
function agentDelete($num) {
mysql_query("delete from agent_dentretien where num_pers = '$num'");
mysql_query("delete from contrat_travail where num_pers1 = '$num'");
mysql_query("delete from information where num_pers1 = '$num'");
mysql_query("delete from absence where num_pers = '$num'");
}
if (isset($_GET['id']))
$mat = $_GET['id'];
else
$mat = "";
agentDelete($mat) ;
header("Location: consult_agtent.php");
?>