par
xavierm83 » 09 mars 2006, 12:52
Bonjour,
J'aimerais bien demander une confirmation pour ajouter des infos dans la base de données mais le bouton 'Confirm' ne marche pas et je ne sais pas comment faire ...
En fait, j'ai fait un formulaire ou je demande de rentrer les différents champs et je teste si certains ont été remplis et j'ai déjà testé l'ajout et ca marche mais j'ai un problème lors de la confirmation ... il m'affiche bien les infos qu'on a remplies mais il me met quand meme une erreur ( Notice: Undefined index: confirm in c:\skills\create_client.php on line 71 correspondant à if(($_POST['confirm']) && ($_POST['confirm'] == 'Confirm')). Et le bouton confirm ne marche pas du tout, rien ne se passe ...
Avez vous une idée ?
Serait il possible aussi d'avoir une combobox qui demande la confirmation de l'ajout et si on clique sur yes il entrera les infos dans la bd ...
Un grand merci pour votre aide,
Voici le code :
echo "<center><font color='#669999' size='4'>CREATE A CLIENT</font></center>";
$client_name = "";
$adress_1 = "";
$adress_2 = "";
$adress_3 = "";
$phone1 = "";
$phone2 = "";
$phone3 = "";
$phone4 = "";
$phone5 = "";
$city_CP ="";
$city_name = "";
$fax = "";
$rc_location = "";
$special_expenses_day = "";
$rc_num = "";
$special_expenses_months = "";
$risk = "";
$partner = "";
$comments = "";
if (isset($_POST['add']) && $_POST['add'] == 'Add this client'){
$client_name = $_POST['client_name'];
$adress_1 = $_POST['address_1'];
$adress_2 = $_POST['address_2'];
$adress_3 = $_POST['address_3'];
$phone1 = $_POST['phone1'];
$phone2 = $_POST['phone2'];
$phone3 = $_POST['phone3'];
$phone4 = $_POST['phone4'];
$phone5 = $_POST['phone5'];
$city_CP = $_POST['city_CP'];
$city_name = $_POST['city_name'];
$fax = $_POST['fax'];
$vat = $_POST['vat'];
$rc_location = $_POST['rc_location'];
$special_expenses_day = $_POST['special_expenses_day'];
$rc_num = $_POST['rc_num'];
$special_expenses_month = $_POST['special_expenses_month'];
$risk = $_POST['risk'];
$partner = $_POST['partner'];
//$comments = $_POST['comments'];
$country = $_POST['country'];
$sectors= $_POST['sectors'];
if (!(empty($client_name))&& !(empty($adress_1))&& !(empty($phone1)) && !(empty($city_CP)) && !(empty($city_name))){
$etatok="ok";
$requete = "SELECT client_name FROM client WHERE client_name= '".$client_name."'";
$conn=mysql_connect($host,$login,$pswd) or die("Erreur lors de la connexion à la BD : ".mysql_error());
mysql_select_db($bd,$conn) or die("Erreur lors de la seclection de la BD : ".mysql_error());
$retour=mysql_query($requete,$conn) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
if (mysql_num_rows($retour) > 0) {
echo "<br>!!! This account name is already used !!! \n";
$etatok = "ko";
}
if($etatok=="ok"){
if(($_POST['confirm']) && ($_POST['confirm'] == 'Confirm')){
$requete = "INSERT INTO client(client_name,adress_1, adress_2, adress_3, phone1, phone2, phone3, phone4, phone5,
city_CP, city_name, fax, vat, rc_location, special_expenses_day, rc_num, special_expenses_months, risk, partner,
comments, refnuncountry, refnumsector, actifcli)
VALUES ('$client_name', '$adress_1' ,'$adress_2', '$adress_3', '$phone1', '$phone2', '$phone3', '$phone4',
'$phone5', '$city_CP', '$city_name', '$fax', '$vat', '$rc_location', '$special_expenses_day', '$rc_num', '$special_expenses_month',
'$risk', '$partner', '$comments', '$country', '$sectors', '1')";
$conn=mysql_connect($host,$login,$pswd) or die("Erreur lors de la connexion à la BD : ".mysql_error());
mysql_select_db($bd,$conn) or die("Erreur lors de la seclection de la BD : ".mysql_error());
$retour=mysql_query($requete,$conn) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
echo "ajout effectué";
}
else{
echo "<table border=0 width=80% cellspacing=1 cellpadding=1 align ='middle'>";
echo "<tr><TD class=box2 width=20% align=right >Account Name : </TD><TD> $client_name</TD>";
echo "<TD width=20% align=right>Address 1 : </TD><TD> $adress_1</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 1 : </TD><TD> $phone1</TD>";
echo "<TD class=box2 width=20% align=right>Address 2 : </TD><TD> $adress_2</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 2 : </TD><TD> $phone2</TD>";
echo "<TD class=box2 width=20% align=right>Address 3 : </TD><TD>$adress_3</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 3 :</TD><TD> $phone3</TD>";
echo "<TD class=box2 width=20% align=right>City Postal Code : </TD><TD> $city_CP</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 4 : </TD><TD> $phone4</TD>";
echo "<TD class=box2 width=20% align=right>City Name :</TD><TD> $city_name</TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>Phone 5 : </TD><TD> $phone5</TD>";
echo "<TD class=box2 width=20% align=right>Country : </TD><TD>$country</TD>";
echo "<tr><TD class=box2 width=20% align=right>Fax : </TD><TD> $fax</TD>";
echo "<tr><TD class=box2 width=20% align=right>VAT : </TD><TD> $vat</TD>";
echo "<tr><TD class=box2 width=20% align=right>RC Location : </TD><TD> $rc_location</TD>";
echo "<TD class=box2 width=20% align=right>Special Expenses - Day : </TD><TD> $special_expenses_day </TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>RC Number : </TD><TD>$rc_num</TD>";
echo "<TD class=box2 width=22% align=right>Special Expenses - Month :</TD><TD> $special_expenses_month</TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>Risk : </TD><TD> $risk </TD>";
echo "<TD class=box2 width=20% align=right>Partner : </TD><TD> $partner </TD>";
//echo "<tr><TD class=box2 width=20% align=right>Comments : </TD><TD class=text><textarea cols=50 rows=7 style=\"height: 150px; width: 100%;name=comments class=textbox></textarea></TD>";
//echo "<TR><TD class=box2 width=20% align=right>Sector</TD><TD class=text>";
echo "</TD></TR></table>";
echo "<p align=center><input type='submit' name='confirm' value='Confirm'>";
echo "<p align=center><a href='display_cli_temp.php'> Back </a>";
}
}
}
else{
$logOK = 'ko';
echo "\n!!! Fill in ALL the requested fields!!! ";
}
}
else {
echo "<form name='create_client' method='post' action='create_client.php'>" ;
echo "<table border=0 width=80% cellspacing=1 cellpadding=1>";
echo "<tr><TD class=box2 width=20% align=right>Account Name </TD><TD class=text><input type=text size=30 name=client_name class=textbox>*</TD>";
echo "<TD class=box2 width=20% align=right>Address 1 </TD><TD class=text><input type=text size=30 name=address_1 class=textbox>*</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 1 </TD><TD class=text><input type=text name=phone1 size=20 class=textbox>*</TD>";
echo "<TD class=box2 width=20% align=right>Address 2</TD><TD class=text><input type=text size=30 name=address_2 class=textbox></TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 2</TD><TD class=text><input type=text name=phone2 size=20 class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>Address 3</TD><TD class=text><input type=text size=30 name=address_3 class=textbox></TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 3</TD><TD class=text><input type=text name=phone3 size=20 class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>City Postal Code </TD><TD class=text><input type=text size=6 name=city_CP class=textbox>*</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 4</TD><TD class=text><input type=text name=phone4 size=20 class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>City Name *</TD><TD class=text><input type=text size=30 name=city_name class=textbox></TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>Phone 5</TD><TD class=text><input type=text name=phone5 size=20 class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>Country</TD><TD class=text>";
echo "<select class='textbox' name='country'>";
$requete="select country_code,country_desc from countries order by country_desc";
$conn=mysql_connect($host,$login,$pswd) or die("Erreur lors de la connexion à la BD : ".mysql_error());
mysql_select_db($bd,$conn) or die("Erreur lors de la seclection de la BD : ".mysql_error());
$retour=mysql_query($requete,$conn) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb_countries=mysql_numrows($retour);
$c=0;
while ( $c < $nb_countries)
{
$countries = mysql_result($retour,$c,"country_desc");
$countries_code= mysql_result($retour,$c,"country_code");
echo "<option value=$countries_code>$countries</option>";
$c++;
}
echo "</select></td>";
echo "<tr><TD class=box2 width=20% align=right>Fax</TD><TD class=text><input type=text name=fax size=20 class=textbox></TD>";
echo "<tr><TD class=box2 width=20% align=right>VAT</TD><TD class=text><input type=text size=20 name=vat class=textbox></TD>";
echo "<tr><TD class=box2 width=20% align=right>RC Location</TD><TD class=text><input type=text size=20 name=rc_location class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>Special Expenses - Day</TD><TD class=text><input type=text size=5 name=special_expenses_day class=textbox></TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>RC Number</TD><TD class=text><input type=text size=20 name=rc_num class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>Special Expenses - Month</TD><TD class=text><input type=text size=5 name=special_expenses_month class=textbox></TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>Risk</TD><TD class=text><select name=risk class=textbox><option value=no selected>No</option><option value=yes>Yes</option></select></TD>";
echo "<TD class=box2 width=20% align=right>Partner</TD><TD class=text><select name=partner class=textbox><option value=no selected>No</option><option value=yes>Yes</option></select></TD>";
echo "<tr><TD class=box2 width=20% align=right>Comments</TD><TD class=text><textarea cols=50 rows=7 style=\"height: 150px; width: 100%;name=comments class=textbox></textarea></TD>";
echo "<TR><TD class=box2 width=20% align=right>Sector</TD><TD class=text>";
echo "<select class='textbox' name='sectors'>";
$requete= "SELECT sector_num, description from sectors order by description ";
$conn=mysql_connect($host,$login,$pswd) or die("Erreur lors de la connexion à la BD : ".mysql_error());
mysql_select_db($bd,$conn) or die("Erreur lors de la seclection de la BD : ".mysql_error());
$retour=mysql_query($requete,$conn) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb_sectors=mysql_numrows($retour);
$s=0;
while ($s<$nb_sectors)
{
$sector = mysql_result($retour,$s,"description");
$sectornum = mysql_result($retour,$s,"sector_num");
echo "<option value=$sectornum>$sector</option>";
$s++;
}
echo "</select>";
echo "</TD></TR></table>";
echo "<p align=center><input type='submit' name='add' value='Add this client'>";
echo "<p align=center><a href='display_cli_temp.php'> Back </a>";
mysql_close();
}
?>
Un tout grand merci pour votre aide,
Bonjour,
J'aimerais bien demander une confirmation pour ajouter des infos dans la base de données mais le bouton 'Confirm' ne marche pas et je ne sais pas comment faire ...
En fait, j'ai fait un formulaire ou je demande de rentrer les différents champs et je teste si certains ont été remplis et j'ai déjà testé l'ajout et ca marche mais j'ai un problème lors de la confirmation ... il m'affiche bien les infos qu'on a remplies mais il me met quand meme une erreur ( Notice: Undefined index: confirm in c:\skills\create_client.php on line 71 correspondant à if(($_POST['confirm']) && ($_POST['confirm'] == 'Confirm')). Et le bouton confirm ne marche pas du tout, rien ne se passe ...
Avez vous une idée ?
Serait il possible aussi d'avoir une combobox qui demande la confirmation de l'ajout et si on clique sur yes il entrera les infos dans la bd ...
Un grand merci pour votre aide,
Voici le code :
[php]
echo "<center><font color='#669999' size='4'>CREATE A CLIENT</font></center>";
$client_name = "";
$adress_1 = "";
$adress_2 = "";
$adress_3 = "";
$phone1 = "";
$phone2 = "";
$phone3 = "";
$phone4 = "";
$phone5 = "";
$city_CP ="";
$city_name = "";
$fax = "";
$rc_location = "";
$special_expenses_day = "";
$rc_num = "";
$special_expenses_months = "";
$risk = "";
$partner = "";
$comments = "";
if (isset($_POST['add']) && $_POST['add'] == 'Add this client'){
$client_name = $_POST['client_name'];
$adress_1 = $_POST['address_1'];
$adress_2 = $_POST['address_2'];
$adress_3 = $_POST['address_3'];
$phone1 = $_POST['phone1'];
$phone2 = $_POST['phone2'];
$phone3 = $_POST['phone3'];
$phone4 = $_POST['phone4'];
$phone5 = $_POST['phone5'];
$city_CP = $_POST['city_CP'];
$city_name = $_POST['city_name'];
$fax = $_POST['fax'];
$vat = $_POST['vat'];
$rc_location = $_POST['rc_location'];
$special_expenses_day = $_POST['special_expenses_day'];
$rc_num = $_POST['rc_num'];
$special_expenses_month = $_POST['special_expenses_month'];
$risk = $_POST['risk'];
$partner = $_POST['partner'];
//$comments = $_POST['comments'];
$country = $_POST['country'];
$sectors= $_POST['sectors'];
if (!(empty($client_name))&& !(empty($adress_1))&& !(empty($phone1)) && !(empty($city_CP)) && !(empty($city_name))){
$etatok="ok";
$requete = "SELECT client_name FROM client WHERE client_name= '".$client_name."'";
$conn=mysql_connect($host,$login,$pswd) or die("Erreur lors de la connexion à la BD : ".mysql_error());
mysql_select_db($bd,$conn) or die("Erreur lors de la seclection de la BD : ".mysql_error());
$retour=mysql_query($requete,$conn) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
if (mysql_num_rows($retour) > 0) {
echo "<br>!!! This account name is already used !!! \n";
$etatok = "ko";
}
if($etatok=="ok"){
if(($_POST['confirm']) && ($_POST['confirm'] == 'Confirm')){
$requete = "INSERT INTO client(client_name,adress_1, adress_2, adress_3, phone1, phone2, phone3, phone4, phone5,
city_CP, city_name, fax, vat, rc_location, special_expenses_day, rc_num, special_expenses_months, risk, partner,
comments, refnuncountry, refnumsector, actifcli)
VALUES ('$client_name', '$adress_1' ,'$adress_2', '$adress_3', '$phone1', '$phone2', '$phone3', '$phone4',
'$phone5', '$city_CP', '$city_name', '$fax', '$vat', '$rc_location', '$special_expenses_day', '$rc_num', '$special_expenses_month',
'$risk', '$partner', '$comments', '$country', '$sectors', '1')";
$conn=mysql_connect($host,$login,$pswd) or die("Erreur lors de la connexion à la BD : ".mysql_error());
mysql_select_db($bd,$conn) or die("Erreur lors de la seclection de la BD : ".mysql_error());
$retour=mysql_query($requete,$conn) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
echo "ajout effectué";
}
else{
echo "<table border=0 width=80% cellspacing=1 cellpadding=1 align ='middle'>";
echo "<tr><TD class=box2 width=20% align=right >Account Name : </TD><TD> $client_name</TD>";
echo "<TD width=20% align=right>Address 1 : </TD><TD> $adress_1</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 1 : </TD><TD> $phone1</TD>";
echo "<TD class=box2 width=20% align=right>Address 2 : </TD><TD> $adress_2</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 2 : </TD><TD> $phone2</TD>";
echo "<TD class=box2 width=20% align=right>Address 3 : </TD><TD>$adress_3</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 3 :</TD><TD> $phone3</TD>";
echo "<TD class=box2 width=20% align=right>City Postal Code : </TD><TD> $city_CP</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 4 : </TD><TD> $phone4</TD>";
echo "<TD class=box2 width=20% align=right>City Name :</TD><TD> $city_name</TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>Phone 5 : </TD><TD> $phone5</TD>";
echo "<TD class=box2 width=20% align=right>Country : </TD><TD>$country</TD>";
echo "<tr><TD class=box2 width=20% align=right>Fax : </TD><TD> $fax</TD>";
echo "<tr><TD class=box2 width=20% align=right>VAT : </TD><TD> $vat</TD>";
echo "<tr><TD class=box2 width=20% align=right>RC Location : </TD><TD> $rc_location</TD>";
echo "<TD class=box2 width=20% align=right>Special Expenses - Day : </TD><TD> $special_expenses_day </TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>RC Number : </TD><TD>$rc_num</TD>";
echo "<TD class=box2 width=22% align=right>Special Expenses - Month :</TD><TD> $special_expenses_month</TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>Risk : </TD><TD> $risk </TD>";
echo "<TD class=box2 width=20% align=right>Partner : </TD><TD> $partner </TD>";
//echo "<tr><TD class=box2 width=20% align=right>Comments : </TD><TD class=text><textarea cols=50 rows=7 style=\"height: 150px; width: 100%;name=comments class=textbox></textarea></TD>";
//echo "<TR><TD class=box2 width=20% align=right>Sector</TD><TD class=text>";
echo "</TD></TR></table>";
echo "<p align=center><input type='submit' name='confirm' value='Confirm'>";
echo "<p align=center><a href='display_cli_temp.php'> Back </a>";
}
}
}
else{
$logOK = 'ko';
echo "\n!!! Fill in ALL the requested fields!!! ";
}
}
else {
echo "<form name='create_client' method='post' action='create_client.php'>" ;
echo "<table border=0 width=80% cellspacing=1 cellpadding=1>";
echo "<tr><TD class=box2 width=20% align=right>Account Name </TD><TD class=text><input type=text size=30 name=client_name class=textbox>*</TD>";
echo "<TD class=box2 width=20% align=right>Address 1 </TD><TD class=text><input type=text size=30 name=address_1 class=textbox>*</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 1 </TD><TD class=text><input type=text name=phone1 size=20 class=textbox>*</TD>";
echo "<TD class=box2 width=20% align=right>Address 2</TD><TD class=text><input type=text size=30 name=address_2 class=textbox></TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 2</TD><TD class=text><input type=text name=phone2 size=20 class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>Address 3</TD><TD class=text><input type=text size=30 name=address_3 class=textbox></TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 3</TD><TD class=text><input type=text name=phone3 size=20 class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>City Postal Code </TD><TD class=text><input type=text size=6 name=city_CP class=textbox>*</TD>";
echo "<tr><TD class=box2 width=20% align=right>Phone 4</TD><TD class=text><input type=text name=phone4 size=20 class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>City Name *</TD><TD class=text><input type=text size=30 name=city_name class=textbox></TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>Phone 5</TD><TD class=text><input type=text name=phone5 size=20 class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>Country</TD><TD class=text>";
echo "<select class='textbox' name='country'>";
$requete="select country_code,country_desc from countries order by country_desc";
$conn=mysql_connect($host,$login,$pswd) or die("Erreur lors de la connexion à la BD : ".mysql_error());
mysql_select_db($bd,$conn) or die("Erreur lors de la seclection de la BD : ".mysql_error());
$retour=mysql_query($requete,$conn) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb_countries=mysql_numrows($retour);
$c=0;
while ( $c < $nb_countries)
{
$countries = mysql_result($retour,$c,"country_desc");
$countries_code= mysql_result($retour,$c,"country_code");
echo "<option value=$countries_code>$countries</option>";
$c++;
}
echo "</select></td>";
echo "<tr><TD class=box2 width=20% align=right>Fax</TD><TD class=text><input type=text name=fax size=20 class=textbox></TD>";
echo "<tr><TD class=box2 width=20% align=right>VAT</TD><TD class=text><input type=text size=20 name=vat class=textbox></TD>";
echo "<tr><TD class=box2 width=20% align=right>RC Location</TD><TD class=text><input type=text size=20 name=rc_location class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>Special Expenses - Day</TD><TD class=text><input type=text size=5 name=special_expenses_day class=textbox></TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>RC Number</TD><TD class=text><input type=text size=20 name=rc_num class=textbox></TD>";
echo "<TD class=box2 width=20% align=right>Special Expenses - Month</TD><TD class=text><input type=text size=5 name=special_expenses_month class=textbox></TD></TR>";
echo "<tr><TD class=box2 width=20% align=right>Risk</TD><TD class=text><select name=risk class=textbox><option value=no selected>No</option><option value=yes>Yes</option></select></TD>";
echo "<TD class=box2 width=20% align=right>Partner</TD><TD class=text><select name=partner class=textbox><option value=no selected>No</option><option value=yes>Yes</option></select></TD>";
echo "<tr><TD class=box2 width=20% align=right>Comments</TD><TD class=text><textarea cols=50 rows=7 style=\"height: 150px; width: 100%;name=comments class=textbox></textarea></TD>";
echo "<TR><TD class=box2 width=20% align=right>Sector</TD><TD class=text>";
echo "<select class='textbox' name='sectors'>";
$requete= "SELECT sector_num, description from sectors order by description ";
$conn=mysql_connect($host,$login,$pswd) or die("Erreur lors de la connexion à la BD : ".mysql_error());
mysql_select_db($bd,$conn) or die("Erreur lors de la seclection de la BD : ".mysql_error());
$retour=mysql_query($requete,$conn) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$nb_sectors=mysql_numrows($retour);
$s=0;
while ($s<$nb_sectors)
{
$sector = mysql_result($retour,$s,"description");
$sectornum = mysql_result($retour,$s,"sector_num");
echo "<option value=$sectornum>$sector</option>";
$s++;
}
echo "</select>";
echo "</TD></TR></table>";
echo "<p align=center><input type='submit' name='add' value='Add this client'>";
echo "<p align=center><a href='display_cli_temp.php'> Back </a>";
mysql_close();
}
?>[/php]
Un tout grand merci pour votre aide,