emprunt d'un livre de la bibliotheque
emprunt d'un livre de la bibliotheque
<?php
//mysql_connect('localhost','root','') or die('erreur de connexion');
//mysql_select_db('bibliotheque')or die('base inexistante');
include('connexion.php');
$c=$_POST['cin'];
$r=$_POST['ref'];
$d=date('Y-m-d');
$req1="select * from abonne where cin='$c'";
$res1=mysql_query($req1);
$n1=mysql_num_rows($res1);
if ($n1==0) {echo('abonné non inscrit'); header('location:inscription abonné.htm');}
else
{
$req1="select * from livre where disponibilite='N' and reference='$r' ";
$res1=mysql_query($req1);
$n1=mysql_num_rows($res1);
if ($n1!=0) {echo('livre déja emprunté');}
else
{
$req2="insert into emprunt values('$c','$r','$d')";
$res2=mysql_query($req2);
$nn=mysql_affected_rows();
if ($nn!=0) {echo('emprunt ajouté avec succès');}
$req3="update livre set disponibilite='N' where reference='$r'";
$res3=mysql_query($req3);
$nn=mysql_affected_rows();
}
}
?>
//mysql_connect('localhost','root','') or die('erreur de connexion');
//mysql_select_db('bibliotheque')or die('base inexistante');
include('connexion.php');
$c=$_POST['cin'];
$r=$_POST['ref'];
$d=date('Y-m-d');
$req1="select * from abonne where cin='$c'";
$res1=mysql_query($req1);
$n1=mysql_num_rows($res1);
if ($n1==0) {echo('abonné non inscrit'); header('location:inscription abonné.htm');}
else
{
$req1="select * from livre where disponibilite='N' and reference='$r' ";
$res1=mysql_query($req1);
$n1=mysql_num_rows($res1);
if ($n1!=0) {echo('livre déja emprunté');}
else
{
$req2="insert into emprunt values('$c','$r','$d')";
$res2=mysql_query($req2);
$nn=mysql_affected_rows();
if ($nn!=0) {echo('emprunt ajouté avec succès');}
$req3="update livre set disponibilite='N' where reference='$r'";
$res3=mysql_query($req3);
$nn=mysql_affected_rows();
}
}
?>
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|