salut tout le monde.
je veux d'aprés ce qui existe dans mes différents tables de ma base de données mettre a jours d'autre table.
plus claire je veux inserrer une reservation d'une chambre donc je vai m-a-j la table reservation,la table clients ,la table hors_ser et la table ch_hs.
donc je vai tout d'abord testé si le client existe déja ou non et faire ce qui est necessaire et le second teste c'est de voir si la periode hors_ser existe déja ou non .
ce que je fait me donne une erreur puisque a chaque fois il me inscrit dans la table hors_ser meme si la periode est la meme .vueillez m'aidé a résoudre ça et merci bien d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
 
 
$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) && ($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
}
 
 
 
	}
 
	}//if mail
	else
			{//mail
?>
<script language="javascript">
  alert("vérifiez votre adresse e-mail.merci!");
  window.location.replace('reservation.php');
</script>
<?php
salut et bon code a tous