Location: PHPKode > projects > weddinglist > weddinglist/main.php
<?
//---------------------------------------------------------------------------------------------------
//							
//	fdrouin -  wedding list
//	
//	Francis DROUIN
//	http://fdrouin.free.fr
//	hide@address.com	
//
//---------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------
//	MAIN
//-----------------------------------------------------------------------------------------------------------------------------------------

/* accès aux données de configuration de l'application */
include("prive/conf.php");
if($langue=="") {$langue=$dft_langue;}
require("include/${langue}.php");
/*connection à la base de donnée MySQL  paramètres dans conf.php  */
DBinfo();
table_Info();  //permet l acces aux nom des tables 
$connection = @mysql_connect("$DBHost", "$DBUser", "$DBPass")  
    or die("Couldn't connect."); 

$db = @mysql_select_db($DBName, $connection) 
    or die("Couldn't select database."); 
include($hautpage);
/* boucle principale */
switch($action) {


//-----------------------------------------------------------------------------------------------------------------------------------------
//	AIDE / HELP
//-----------------------------------------------------------------------------------------------------------------------------------------

case "aide":
include("include/${langue}_help.htm");
break;

//-----------------------------------------------------------------------------------------------------------------------------------------
//	Afficher la liste
//-----------------------------------------------------------------------------------------------------------------------------------------
case "liste":
?>
<body bgcolor="#FFFFF0">
<?
				/* on affiche la liste */
				include ("liste.php");		
break;
//-----------------------------------------------------------------------------------------------------------------------------------------
//	validation du choix
//-----------------------------------------------------------------------------------------------------------------------------------------
case "valider":
				/* valider le choix et reafficher selection */
		echo "<b><center><br><br><h6>$mess[14]</b></center></h6><br><br>\n";
?>
<body bgcolor="#FFFFF0">	
<table id="TableListe" cellspacing="1" cellpadding="0" width="379" border="0">
	<tr>
		<td bgcolor="#ffffff" ><? echo $mess[5]?><br><br><br></td>
		<td align="right" bgcolor="#ffffff"><? echo $mess[9]?><br><br><br></td>
		<td align="right" bgcolor="#ffffff"><? echo $mess[10]?><br><br><br></td>
	</tr>
<?			
		$i=0;
		$j=0;
		$desc ="";          //description du cadeau
		echo "<form name='f_valid'  method=\"post\"  action=\"main.php\">\n";
	while (list($key,$value) =each($HTTP_POST_VARS))
		{	
    $value = stripslashes($value);
		//echo "debug   $i  $key   $value<br>\n";
		if (substr($key,0,3)== "NOM") {$nom=$value;}
		if (substr($key,0,3)== "NUM") {$num=$value;}
		if (substr($key,0,7)== "QTE_LIS") {$qtinit=$value;}
		if (substr($key,0,7)== "QTE_RES") {$qte=$value;}
		if (substr($key,0,8)== "MONT_RES") {$montant=$value;}
		$j=$j+1;
		  if ($j == 7)
		  {
		   if ($qte >0)
			 {
	      echo "<tr valign=\"top\">\n";
		    echo "<td bgcolor=\"#ffffff\">$nom&nbsp;<input name=\"NUM_CADEAU_$i\" id=\"NUM_CADEAU_$i\" type=\"hidden\" value=\"$num\" /></td>\n";
		    echo "<td bgcolor=\"#ffffff\" align=\"right\">$qte\n";
				echo "<td bgcolor=\"#ffffff\" align=\"right\">$montant  €\n";
				echo "<input name=\"QTE_RES_$i\" type=\"hidden\" size=\"2\" id=\"QTE_RES_$i\" value =\"$qte\">\n";
				echo "<input name=\"QTE_LIST_$i\" type=\"hidden\" size=\"2\" id=\"QTE_LIST_$i\" value =\"$qtinit\">\n";
				echo "</td>\n";
				$desc = $desc."<br>".$nom."     qte=".$qte."    prix=".$montant." €";
			  $i=$i+1;
			 }
			 $j=0;
		  }	 
    }
	if ($PARTICIPATION >0)
	{
	echo "<tr valign=\"top\">\n";
	echo "<td bgcolor=\"#ffffff\">$mess[11]</td>\n";
	echo "<td bgcolor=\"#ffffff\" align=\"right\">--</td>\n";
	echo "<td bgcolor=\"#ffffff\" align=\"right\">$PARTICIPATION  €</td>\n";
	$desc = $desc."<br>Participation    ".$PARTICIPATION." €";
	}	
	echo "<tr valign=\"top\">\n";
	echo "<td bgcolor=\"#ffffff\">_______</td>\n";
	echo "<td bgcolor=\"#ffffff\" align=\"right\"></td>\n";
	echo "<td bgcolor=\"#ffffff\" align=\"right\">_____________</td>\n";	
	echo "<tr valign=\"top\">\n";
	echo "<td bgcolor=\"#ffffff\">$mess[8]</td>\n";
	echo "<td bgcolor=\"#ffffff\" align=\"right\">--   </td>\n";
	echo "<td bgcolor=\"#ffffff\" align=\"right\">$MONTANT_TOTAL  €</td>\n";	
		  echo "</table>\n";
	echo "<center><br><h6>$mess[15]</h6><br>\n";
	echo "$mess[16]:\n";
	echo "<input type=\"text\" name=\"USER\">\n";
	echo "E Mail :\n";
	echo "<input type=\"text\" name=\"EMAIL\">\n";	
	echo "<br><textarea rows=\"10\" name=\"S1\" cols=\"91\"></textarea>\n";	
		echo "<br><input type=\"hidden\" name=\"action\" value=\"confirmer\">\n";
	echo "<br><br><br><input type=\"hidden\" name=\"langue\" value=\"$langue\">\n";
	echo "<input class=\"send\" type=\"submit\" name=\"Submit\" value=\"$mess[17]\"> $mess[22] \n";
	echo "<a id=\"linkbutton_retour\" class=\"arial16blue\" href=\"main.php?action=liste&langue=$langue\">&nbsp;&nbsp;&nbsp;&nbsp;$mess[18]</a>\n";
	echo "<input type=\"hidden\" name=\"MONTANT_TOTAL\" value=\"$MONTANT_TOTAL\">\n";
	 echo "<input type=\"hidden\" name=\"action\" value=\"confirmer\">\n";
	 echo "<input type=\"hidden\" name=\"desc\" value=\"$desc\">\n";
	 echo "</form>\n";
?>
<p><? echo $mess[19]?></p>
<br>
<? echo $mess[21]?>
<? echo $mess[23]?>
</center>
<?	  	
break;

//-----------------------------------------------------------------------------------------------------------------------------------------
//	Confirmation définitive du choix
//-----------------------------------------------------------------------------------------------------------------------------------------
case "confirmer":
	while (list($key,$value) =each($HTTP_POST_VARS))
	{	
    $value = stripslashes($value);
		if (substr($key,0,3)== "NUM") {$num=$value;}
		if (substr($key,0,7)== "QTE_RES") {$qte=$value;}
		if (substr($key,0,7)== "QTE_LIS") 
		  {
		    $qtinit=$value;
		    $qte=$qtinit-$qte;  // quantité restante
		    if ($qte <0) {$qte=0;}
	        //mise à jour des quantités
			  $commande = "update $table_list Set quantité='$qte' where numero='$num'";
			  $resultat = mysql_query ($commande, $connection) or die ("Liste non disponible");
		  }	 
   }
// insert dabs $table_user du nouvl enreg
  $S1=$desc."<br>___________________<br>".$S1;
	$nom = strip_tags($USER);
	$message = nl2br($S1);
	$email = strtolower($EMAIL);
	$date = time();
	$montant = $MONTANT_TOTAL;
 $message = addslashes($message);
 $query = "INSERT INTO $table_user VALUES('','$message','$nom','$email','$date','$montant')";
 mysql_query($query) or die ("<p align=center class=text>Ajout du message sur table user impossible</p>");
?>
<body background="images/clouds.gif" onmousemove="cursor()">
<img id="trail" style="visibility:hidden" src="images/tahiti.gif">
<br><br><br><br>
<center><img src="images/tahiti1.jpg" width="350" height="233"></center>
              <br><br><br><h4><center><? echo $mess[20]?></h4>

</center>
<?
	 
break;

//-----------------------------------------------------------------------------------------------------------------------------------------
//	Administrer la liste
//-----------------------------------------------------------------------------------------------------------------------------------------
case "admin":
				/* on affiche la liste */
				include ("admliste.php");
break;
//-----------------------------------------------------------------------------------------------------------------------------------------
//	mise à jour des quantités et prix
//-----------------------------------------------------------------------------------------------------------------------------------------
case "majtable":
	while (list($key,$value) =each($HTTP_POST_VARS))
	{	
    //echo "$key      $value<br>\n";
		$value = stripslashes($value);
		if (substr($key,0,3)== "NUM") {$num=$value;}
		if (substr($key,0,7)== "QTE_RES") {$qte=$value;}
		if (substr($key,0,6)== "NOM_FR") {$nom_fr=$value;}
		if (substr($key,0,6)== "NOM_EN") {$nom_en=$value;}
		if (substr($key,0,7)== "MONT_RE") 
		  {
		    $montant=$value;
		    if ($qte > 0) 
				{
	        //mise à jour quantité et prix
			  $commande = "update $table_list Set desc_fr='$nom_fr', desc_en='$nom_en',quantité='$qte',prix='$montant' where numero='$num'";
			  $resultat = mysql_query ($commande, $connection) or die ("Liste non disponible");
				}
		  } 
   }
	 /* inserer le nb de lignes indiquées  */
	 $i = $nbligne;
	 while ($i > 0)
	 {
	  $query = "INSERT INTO $table_list VALUES ('', 'Description en francais', 'Description in English', '', '', '0', '0')";
   mysql_query($query) or die ("<p align=center class=text>Ajout du message sur table user impossible</p>");
   $i= $i -1;
	 }			
					/* on affiche la liste avec les nouvelles valeurs*/
			  include ("admliste.php");
break;
//-----------------------------------------------------------------------------------------------------------------------------------------
//	supprimer toutes les lignes
//-----------------------------------------------------------------------------------------------------------------------------------------
case "raztable":
				/* on reconstitue la liste initiale*/
	  $query = "Delete from $table_list ";	
   mysql_query($query) or die ("<p align=center class=text>Delete table user impossible</p>");	
	 			$query="INSERT INTO $table_list VALUES ('', 'voyage en avion', 'flight travel', '', '1200', 2, 0)";
					   mysql_query($query) or die ("<p align=center class=text>Insert table user impossible</p>");
        $query="INSERT INTO $table_list VALUES ('', 'nuit à tahiti', 'Night in Tahiti', '', '250', 5, 0)";
					   mysql_query($query) or die ("<p align=center class=text>Insert table user impossible</p>");
        $query="INSERT INTO $table_list VALUES ('', 'Decouverte des Iles', 'Islands Discovery', '', '250', 7, 0)";
					   mysql_query($query) or die ("<p align=center class=text>Insert table user impossible</p>");
        $query="INSERT INTO $table_list VALUES ('', 'Boissons', 'Drinks', '', '10', 40, 0)";
					   mysql_query($query) or die ("<p align=center class=text>Insert table user impossible</p>");
        $query="INSERT INTO $table_list VALUES ('', 'café', 'Coffee', '', '5', 20, 0)";
	           mysql_query($query) or die ("<p align=center class=text>Insert table user impossible</p>");
				include ("admliste.php");
break;
//-----------------------------------------------------------------------------------------------------------------------------------------
//	Afficher la liste des utilisateurs ayant fait un cadeau
//-----------------------------------------------------------------------------------------------------------------------------------------
case "user":
				/* on affiche la liste */
				include ("listuser.php");		
break;
//---------------------------------------------------------------------------------------------------------------------
//	DEFAUT
//---------------------------------------------------------------------------------------------------------------------

default:
	echo "<form method=\"post\" action=\"index.php\">\n";
	echo "<font face=\"$font\" size=\"2\"";
	echo "><b>Nom :</b>\n";
	echo "<input type=\"text\" name=\"USER\">\n";
	echo "<br><b>E Mail :</b>\n";
	echo "<input type=\"text\" name=\"EMAIL\">\n";
	echo "<input type=\"hidden\" name=\"action\" value=\"verif\">\n";
	echo "<br><br>\n";
	echo "<input class=\"send\" type=\"submit\" name=\"Submit\" value=\"$mess[77]\">\n";
	echo "</font></form>\n";
break;
}
include($baspage);
?>
Return current item: weddinglist