bonjour tout le monde et merci bien pour tous.
bon j'ai un nouveau problème .
je prend l'exemple: j'inserre un client qui existe et une periode qui existe déja .
mon script au lieu d'excuté la premiere condition il passe toujours a la troisiemme.qui peut me dire comment corrigée ça .
c'est le script final:
$req=mysql_query("SELECT num_carte,type_carte,id_clt FROM client");
while($rep=mysql_fetch_array($req))
{
if(($identite==$rep['num_carte']) and ($typ==$rep['type_carte']))
{ $id=$rep['id_clt'];$clt=1; }
}
$req1=mysql_query("SELECT * FROM hors_ser WHERE staut='v' and date_d='$date1' and date_f='$date2'");
if($rep1=mysql_fetch_array($req1))
{
$id_p=$rep1['id_p'];$i=1;
}
if(($clt==1) and ($i==1))
{
$req2=mysql_query("INSERT INTO ch_hs(id_ch,id_p,justification)VALUES('$n_ch','$id_p','reserver')");
$req3=mysql_query("INSERT INTO reservation VALUES('',CURRENT_TIMESTAMP(),'net','$date1','$date2','$obj','$adul','$bebe','$montant','carte bancaire','$id_type','$n_ch','Saidabeya','1','$id','a','v')");
if((!$req2) and (!req3))
{
?>
<script language="javascript">
alert("reservation non validé");
window.location.replace('reservation.php');
</script>
<?php
}
else
{
?>
<script language="javascript">
alert("reservation validé");
window.location.replace('reservation.php');
</script>
<?php
}
}
else if(($clt==0) and ($i==1))
{
$req4=mysql_query("INSERT INTO client VALUES('','$titre','$nom','$prenom','$pays','$adresse','$codep','$ville','$mail','$tel','$fax','$web','$ncc','$tit','$val','$identite','$typ')");
$req5=mysql_query("select id_clt from client where nom='$nom' AND prenom='$prenom'");
$rep5=mysql_fetch_array($req5);
{$id=$rep5['id_clt'];}
$req6=mysql_query("INSERT INTO ch_hs(id_ch,id_p,justification)VALUES('$n_ch','$id_p','reserver')");
$req7=mysql_query("INSERT INTO reservation VALUES('',CURRENT_TIMESTAMP(),'net','$date1','$date2','$obj','$adul','$bebe','$montant','carte bancaire','$id_type','$n_ch','Saidabeya','1','$id','a','v')");
if((!$req4) and (!rep5)and (!req6)and (!req7))
{
?>
<script language="javascript">
alert("reservation non validé");
window.location.replace('reservation.php');
</script>
<?php
}
else
{
?>
<script language="javascript">
alert("reservation validé");
window.location.replace('reservation.php');
</script>
<?php
}
}
else if(($clt==1) and ($i==0))
{
$req8=mysql_query("INSERT INTO hors_ser VALUES('','$date1','$date2','v')");
$req9=mysql_query("select id_p FROM hors_ser WHERE date_d='$date1' AND date_f='$date2'");
$rep9=mysql_fetch_array($req9);
{$id_p=$rep9['id_p'];}
$req10=mysql_query("INSERT INTO ch_hs(id_ch,id_p,justification)VALUES('$n_ch','$id_p','reserver')");
$req11=mysql_query("INSERT INTO reservation VALUES('',CURRENT_TIMESTAMP(),'net','$date1','$date2','$obj','$adul','$bebe','$montant','carte bancaire','$id_type','$n_ch','Saidabeya','1','$id','a','v')");
if((!$req8) and (!rep9)and (!req10)and (!req11))
{
?>
<script language="javascript">
alert("reservation non validé");
window.location.replace('reservation.php');
</script>
<?php
}
else
{
?>
<script language="javascript">
alert("reservation validé");
window.location.replace('reservation.php');
</script>
<?php
}
}
else
{
$req12=mysql_query("INSERT INTO client VALUES('','$titre','$nom','$prenom','$pays','$adresse','$codep','$ville','$mail','$tel','$fax','$web','$ncc','$tit','$val','$identite','$typ')");
$req13=mysql_query("select id_clt from client where nom='$nom' AND prenom='$prenom'");
$rep13=mysql_fetch_array($req13);
{$id=$rep13['id_clt'];}
$req14=mysql_query("INSERT INTO hors_ser VALUES('','$date1','$date2','v')");
$req15=mysql_query("select id_p FROM hors_ser WHERE date_d='$date1' AND date_f='$date2'");
$rep15=mysql_fetch_array($req15);
{$id_p=$rep15['id_p'];}
$req16=mysql_query("INSERT INTO ch_hs(id_ch,id_p,justification)VALUES('$n_ch','$id_p','reserver')");
$req17=mysql_query("INSERT INTO reservation VALUES('',CURRENT_TIMESTAMP(),'net','$date1','$date2','$obj','$adul','$bebe','$montant','carte bancaire','$id_type','$n_ch','Saidabeya','1','$id','a','v')");
if((!$req12) and (!rep13)and (!req14)and (!rep15)and (!req16)and (!req17))
{
?>
<script language="javascript">
alert("reservation non validé");
window.location.replace('reservation.php');
</script>
<?php
}
else
{
?>
<script language="javascript">
alert("reservation validé");
window.location.replace('reservation.php');
</script>
<?php
}
}
merci bien d'avance et bon code.