le 30/04/2005 à 19:51
mouna
form:
=====
<?
include ("config.php");
?>
<form name="souscat" method="POST" action="add_sous_cat_confirm.php">
Sous Categorie: <input type="text" name="Sous_Cat" size="20" maxlength="20">
<?
$connection = mysql_connect("$host", "$user", "$pass") or die(mysql_error());
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = mysql_query ("select * from $table_name_gbook order by catid ASC") or die ("erreur req ".mysql_error());
//le <select> et </select> doit être créé hors de la boucle while, sinon tu en crées un par option.
echo "<select name=\"Cat\">";
while( $sortie = mysql_fetch_array($sql))
{
$Cat = $sortie['Cat'];
$catid = $sortie['catid'];
echo "<option value=\"$catid\">".$Cat."</option>";
}//fin de boucle
echo "</select>";
//after verifying everything, must be inserted then redirected :)
mysql_close ();
?>
<input type="submit" name="submit" value="Ajouter">
</form>
==============
confirm:
======
<?
// settings
include ("config.php");
if(isset($_POST["Sous_Cat"])) $Sous_Cat = $_POST["Sous_Cat"];
else $Sous_Cat = "";
if(isset($_POST['catid'])) $catid = $_POST['catid'];
else $catid = '';
//*****************************************************************************//
// ucfirst=> first letter in capital letter
// strtolower=>all caracters in small letters
// trim =>erase space before and after a sentence or a word
// htmlentities don't allow convert html characters to special characters
//ENT_COMPAT Convertit les guillemets doubles, et ignore les guillemets simples
//ENT_QUOTES Convertit les guillemets doubles et les guillemets simples
// ENT_NOQUOTES Ignore les guillemets doubles et les guillemets simples
//********************************************************************************//
$ip="$_SERVER[REMOTE_ADDR]";
//verify fields
if (empty($Sous_Cat)){ //nom du champ1
echo("<font face=verdana size=2>Sous Cat field is empty</font><br>"); //message qui s'affiche si le visiteur n'a pas rempli ce champ
echo("<a href=\"javascript:history.back()\" class=navfont> Return </a>");
}
elseif (strlen($Sous_Cat)<3){
echo("<font face=verdana size=2>Name < 5</font><br>"); //message qui s'affiche si le visiteur n'a pas rempli ce champ
echo("<a href=\"javascript:history.back()\" class=navfont> Return </a>");
}
else {
//connection
$connection = mysql_connect("$host", "$user", "$pass") or die(mysql_error());
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "INSERT INTO $table_name1 VALUES('','$catid','$Sous_Cat')";
$result = mysql_query($sql,$connection) or die(mysql_error());
//after verifying everything, must be inserted then redirected :)
mysql_close ();
echo ('helllllooooooooooooooooooooooo voir les cat<a href="voir2.php">voir</a>');
}
?>
=====
<?
include ("config.php");
?>
<form name="souscat" method="POST" action="add_sous_cat_confirm.php">
Sous Categorie: <input type="text" name="Sous_Cat" size="20" maxlength="20">
<?
$connection = mysql_connect("$host", "$user", "$pass") or die(mysql_error());
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = mysql_query ("select * from $table_name_gbook order by catid ASC") or die ("erreur req ".mysql_error());
//le <select> et </select> doit être créé hors de la boucle while, sinon tu en crées un par option.
echo "<select name=\"Cat\">";
while( $sortie = mysql_fetch_array($sql))
{
$Cat = $sortie['Cat'];
$catid = $sortie['catid'];
echo "<option value=\"$catid\">".$Cat."</option>";
}//fin de boucle
echo "</select>";
//after verifying everything, must be inserted then redirected :)
mysql_close ();
?>
<input type="submit" name="submit" value="Ajouter">
</form>
==============
confirm:
======
<?
// settings
include ("config.php");
if(isset($_POST["Sous_Cat"])) $Sous_Cat = $_POST["Sous_Cat"];
else $Sous_Cat = "";
if(isset($_POST['catid'])) $catid = $_POST['catid'];
else $catid = '';
//*****************************************************************************//
// ucfirst=> first letter in capital letter
// strtolower=>all caracters in small letters
// trim =>erase space before and after a sentence or a word
// htmlentities don't allow convert html characters to special characters
//ENT_COMPAT Convertit les guillemets doubles, et ignore les guillemets simples
//ENT_QUOTES Convertit les guillemets doubles et les guillemets simples
// ENT_NOQUOTES Ignore les guillemets doubles et les guillemets simples
//********************************************************************************//
$ip="$_SERVER[REMOTE_ADDR]";
//verify fields
if (empty($Sous_Cat)){ //nom du champ1
echo("<font face=verdana size=2>Sous Cat field is empty</font><br>"); //message qui s'affiche si le visiteur n'a pas rempli ce champ
echo("<a href=\"javascript:history.back()\" class=navfont> Return </a>");
}
elseif (strlen($Sous_Cat)<3){
echo("<font face=verdana size=2>Name < 5</font><br>"); //message qui s'affiche si le visiteur n'a pas rempli ce champ
echo("<a href=\"javascript:history.back()\" class=navfont> Return </a>");
}
else {
//connection
$connection = mysql_connect("$host", "$user", "$pass") or die(mysql_error());
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "INSERT INTO $table_name1 VALUES('','$catid','$Sous_Cat')";
$result = mysql_query($sql,$connection) or die(mysql_error());
//after verifying everything, must be inserted then redirected :)
mysql_close ();
echo ('helllllooooooooooooooooooooooo voir les cat<a href="voir2.php">voir</a>');
}
?>