Voila j'ai un formulaire dans lequel j'utilise des menus déroulant lié entre eux + des boutons radio et je dois transmettre le tout via un submit. Mon probleme est au niveau de pays province,ville, enfin je croix
Je tourne en rond, ou mon menu deroulant se met à jour et mon bouton submit ne fonctionne plus ou j'ai le submit qui fonctionne mais c'est le menu deroulant qui ne se met plus a jour. De plus ils ne gardent pas les données si je modifie la valeur de pays
J'ai essayer avec des get, mais je suis blocqué à 255 caracteres.
Voici une partie du code car il y a 14 page normalement je vous le simplifie un peu.
<?php
if (!defined("INDEX_CHECK")) {
die ("<center>You cannot open this page directly</center>");
}
global $user, $nuked, $language;
include("modules/Immo/lang/".$language.".lang.php");
if(!$user){$visiteur="0";}
else{$visiteur=$user[1];}
$ModName = basename( dirname( __FILE__ ) );
if ($visiteur>=nivo_mod($ModName)){
compteur(Immo);
///------------------------------------------
function index()
{
echo"<br><br><center><a href=\"index.php?file=Immo&op=add\">Consulter les annonces</a> - <a href=\"index.php?file=Immo&op=add\">Ajouter une annonce</a> - <a href=\"index.php?file=Immo&&page=edit&op=mister\">Lister et gérer vos annonces</a></center><br><br>";
}
///------------------------------------------
function select_ouinon($valeur)
{
echo" <input name=\"$valeur\" type=\"radio\" value=\"0\" checked>
"._NO."
<input type=\"radio\" name=\"$valeur\" value=\"1\">
"._YES."";
}
///------------------------------------------
function select_nbre8($valeur)
{
echo" <input name=\"$valeur\" type=\"radio\" value=\"0\" checked> 0
<input type=\"radio\" name=\"$valeur\" value=\"1\"> 1
<input type=\"radio\" name=\"$valeur\" value=\"2\"> 2
<input type=\"radio\" name=\"$valeur\" value=\"3\"> 3
<input type=\"radio\" name=\"$valeur\" value=\"4\"> 4
<input type=\"radio\" name=\"$valeur\" value=\"5\"> 5
<input type=\"radio\" name=\"$valeur\" value=\"6\"> 6
<input type=\"radio\" name=\"$valeur\" value=\"7\"> 7
<input type=\"radio\" name=\"$valeur\" value=\"8\"> 8+";
}
//---------------------------------------------------
function add($pseudo,$tel,$fax,$hours,$mail,$site,$pays,$province,$ville,$adresse,$prix,$cadastre,$superfh,$hall,$salon,$comment,$date,$active,$obsol,$url_file)
{
global $language, $user, $nuked, $bgcolor3, $bgcolor1;
OpenTable();
echo" <A HREF=# onClick=\"javascript:window.open('help/".$language."/Immo.html','Help','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,copyhistory=0,menuBar=0,width=350,height=300');return(false)\">
<img src=\"help/help.gif\" border=\"0\" alt=\""._HELP."\"></a><center><H3>"._ADDART."</h3>";
echo" <script language=\"javascript\">
function verifchamps()
{
if (document.formulaire.mail.value.indexOf('@') == -1)
{
alert('"._ERRORMAIL."');
return false;
}
if (document.formulaire.pays.value.length == 0)
{
alert('"._NOPAYS."');
return false;
}
if (document.formulaire.province.value.length == 0)
{
alert('"._NOPROVINCE."');
return false;
}
if (document.formulaire.ville.value.length == 0)
{
alert('"._NOVILLE."');
return false;
}
if (document.formulaire.adresse.value.length == 0)
{
alert('"._NORUE."');
return false;
}
if (document.formulaire.prix.value.length == 0)
{
alert('"._NOPRIX."');
return false;
}
return true;
}
</script>";
$sql=mysql_query("SELECT mail FROM $nuked[prefix]"._users." WHERE pseudo='$user[2]'");
list($mail) = mysql_fetch_array($sql);
echo" <form name=\"formulaire\" method=\"post\" ENCTYPE=\"multipart/form-data\" action=\"index.php?file=Immo&op=do_add\" OnSubmit='return verifchamps();'>
<table width=\"90%\" border=\"0\" align=\"center\" bgcolor=\"$bgcolor1\" cellspacing=\"0\" cellpadding=\"3\">
<tr bgcolor=\"$bgcolor3\">
<td width=\"35%\"><img src=\"themes/nk_classic/images/puce.gif\" border=\"0\" align=\"absmiddle\"> <b>"._SALERINFO."</b></td>
<td width=\"5%\"> </td>
<td width=\"60%\"> </td>
</tr>
<tr>
<td>"._AUTHOR."</td>
<td> </td>
<td>$user[2]</td>
</tr>
<tr>
<td>"._TEL."</td>
<td> </td>
<td>
<input name=\"tel\" type=\"text\" id=\"tel\" value=\"$tel\">
</td>
</tr>
<tr>
<td>"._FAX."</td>
<td> </td>
<td>
<input name=\"fax\" type=\"text\" id=\"fax\" value=\"$fax\">
</td>
</tr>
<tr>
<td>"._HOURS."</td>
<td> </td>
<td>
<input name=\"hours\" type=\"text\" id=\"hours\" value=\"$hours\">
</td>
</tr>
<tr>
<td>"._MAIL."</td>
<td> </td>
<td>
<input name=\"mail\" type=\"text\" id=\"mail\" value=\"$mail\">
</td>
</tr>
<tr>
<td>"._SITE."</td>
<td> </td>
<td>
<input name=\"site\" type=\"text\" id=\"site\" value=\"$site\">
</td>
</tr>
<tr>
<td width=\"35%\">"._PAYS." *</td>
<td width=\"5%\"> </td>
<td width=\"60%\">";
// -----pays-----
echo " <select name=\"pays\" OnChange=\"this.form.action='index.php?file=Immo&op=add';this.form.submit()\">";
if (isset($_REQUEST["pays"]) && $_REQUEST["pays"]) {
echo " <option value=\"$pays\" selected> $pays</option>";
echo " <option value=\"\">----------</option>";
$sql = mysql_query("SELECT pays FROM " . PAYS_TABLE . " ORDER by 'pays'");
while (list($pays) = mysql_fetch_array($sql)){
echo " <option value=\"$pays\"> $pays</option>";
}
}else{
echo " <option value=\"$pays\" selected><b>" ._CHOOSEPAYS. "</b></option>";
$sql = mysql_query("SELECT pays FROM " . PAYS_TABLE . " ORDER by 'pays'");
while (list($pays) = mysql_fetch_array($sql)){
echo " <option value=\"$pays\"> $pays</option>";
}
if (document.formulaire.province.value.length == 0)
{
alert('"._NOPROVINCE."');
return false;
}
}
echo " </select></td></tr>";
// -----provinces-----
if (isset($_REQUEST["pays"]) && $_REQUEST["pays"]) {
$choixpays=$_REQUEST["pays"];
echo " <tr>
<td>"._PROVINCE." *</td>
<td> </td>
<td>
<select name=\"province\" onchange=\"this.form.action='index.php?file=Immo&op=add';this.form.submit()\">";
if (isset($_REQUEST["province"]) && $_REQUEST["province"]) {
echo " <option value=\"$province\" selected> $province</option>";
echo " <option value=\"\">----------</option>";
$sql = mysql_query("SELECT province FROM " . PROVINCE_TABLE . " WHERE pays = '$choixpays' ORDER by 'province'");
while (list($province) = mysql_fetch_array($sql)){
echo " <option value=\"$province\"> $province</option>";
}
}else{
$choixpays=$_REQUEST["pays"];
echo " <option value=\"$province\" selected><b>" ._CHOOSEPROVINCE. "</b></option>";
$sql = mysql_query("SELECT province FROM " . PROVINCE_TABLE . " WHERE pays = '$choixpays' ORDER by 'province'");
while (list($province) = mysql_fetch_array($sql)){
echo " <option value=\"$province\"> $province</option>";
}
if (document.formulaire.ville.value.length == 0)
{
alert('"._NOPROVINCE."');
return false;
}
}
echo " </select></td></tr>";
}
// -----villes-----
if (isset($_REQUEST["province"]) && $_REQUEST["province"] ) {
$choixprovince=$_REQUEST["province"];
echo " <tr>
<td>"._VILLE." *</td>
<td> </td>
<td>
<select name=\"ville\" onchange=\"this.form.action=index.php?file=Immo&op=add';this.form.submit()\">";
if (isset($_REQUEST["ville"]) && $_REQUEST["ville"]) {
echo " <option value=\"$ville\" selected> $ville</option>";
echo " <option value=\"\">----------</option>";
$sql = mysql_query("SELECT ville FROM " . VILLE_TABLE . " WHERE province = '$choixprovince' ORDER by 'ville'");
while (list($ville) = mysql_fetch_array($sql)){
echo " <option value=\"$ville\"> $ville</option>";
}
}else{
$choixprovince=$_REQUEST["province"];
echo " <option value=\"$ville\" selected><b>" ._CHOOSEVILLE. "</b></option>";
$sql = mysql_query("SELECT ville FROM " . VILLE_TABLE . " WHERE province = '$choixprovince' ORDER by 'ville'");
while (list($ville) = mysql_fetch_array($sql)){
echo " <option value=\"$ville\"> $ville</option>";
}
if (document.formulaire.ville.value.length == 0)
{
alert('"._NOPROVINCE."');
return true;
}
}
echo "</select></td></tr>";
}
echo"<tr>
<td>"._ADRESS." *</td>
<td> </td>
<td><input type=\"text\" name=\"adresse\" id=\"adresse\" value=\"$adresse\"></td>
</tr>
</table><br>
<table width=\"90%\" border=\"0\" align=\"center\" bgcolor=\"$bgcolor1\" cellspacing=\"0\" cellpadding=\"3\">
<tr bgcolor=\"$bgcolor3\">
<td width=\"35%\"><div align=\"left\" class=\"Style1\">
<img src=\"themes/nk_classic/images/puce.gif\" border=\"0\" align=\"absmiddle\"> <b>"._ARTINFO."</b></td>
<td width=\"5%\"> </td>
<td width=\"60%\"></td>
</tr>
<tr>
<td>"._PRIX." *</td>
<td> </td>
<td><input type=\"text\" name=\"prix\" id=\"prix\" value=\"$prix\">
€ </td>
</tr>
<tr>
<td>"._CADASTRE."</td>
<td> </td>
<td><input type=\"text\" name=\"cadastre\" value=\"$cadastre\">
€ </td>
</tr>
<tr>
<td>"._SUPERFH." *</td>
<td> </td>
<td><select name=\"superfh\">
<option value=\"5\" selected>"._FROM0TO5."</option>
<option value=\"10\">"._FROM5TO10."</option>
<option value=\"20\">"._FROM10TO20."</option>
<option value=\"50\">"._FROM20TO50."</option>
<option value=\"100\">"._FROM50TO100."</option>
<option value=\"101\">"._MORE100."</option>
</select></td>
</tr>
</table><br>
<table width=\"90%\" border=\"0\" align=\"center\" bgcolor=\"$bgcolor1\" cellspacing=\"0\" cellpadding=\"3\"><tr bgcolor=\"$bgcolor3\">
<td width=\"35%\"><div align=\"left\" class=\"Style1\">
<img src=\"themes/nk_classic/images/puce.gif\" border=\"0\" align=\"absmiddle\"> <b>"._INFODET."</b></td>
<td width=\"5%\"> </td>
<td width=\"60%\"></td>
</tr>
<tr>
<td>"._HALL." * </td>
<td> </td>
<td>";
select_nbre8('hall');
echo" </td>
</tr>
<tr>
<td>"._SALON." *</td>
<td> </td>
<td>";
select_nbre8('salon');
echo" </td>
</tr>
<tr>
<td valign=\"middle\" colspan=\"3\">"._COMMENTS." :
<center><textarea name=\"comment\" cols=\"90\" rows=\"3\" id=\"comment\" value=\"$comment\"></textarea></center></td>
</tr>
</table> <br>
<table width=\"90%\" border=\"0\" align=\"center\" bgcolor=\"$bgcolor1\">
<tr><td><b>"._WHERESCREEN." :</b> <input type=\"file\" name=\"fichiernom\" enctype=\"multipart/form-data\">
</td></tr>
</table>
<br>
<div align=\"center\">
<input name=\"Submit\" type=\"submit\" id=\"submit\" value=\""._SEND."\">
</div>
</form>";
CloseTable();
}
///------------------------------------------
function do_add($pseudo,$tel,$fax,$hours,$mail,$site,$pays,$province,$ville,$adresse,$prix,$cadastre,$superfh,$hall,$salon,$comment,$date,$active,$obsol,$fichiernom)
{
global $fichiernom_name, $user, $nuked;
OpenTable();
$date = time();
$fin = getdate(mktime()+(30*24*60*60));
$obsol = $fin[0];
$pseudo=$user[2];
if ($fichiernom_name!=""){
$filename=$_FILES['fichiernom']['name'];
$url_screen="modules/Immo/annonces/$filename";
move_uploaded_file($_FILES['fichiernom']['tmp_name'], $url_screen) or die ("Upload file failed !!!");}
$pseudo=AddSlashes($pseudo);
$adresse=AddSlashes($adresse);
$cadastre=AddSlashes($cadastre);
$hours=AddSlashes($hours);
$comment=AddSlashes($comment);
$sql=mysql_query(" INSERT INTO $nuked[prefix]"._immo." VALUES ('','$pseudo','$tel','$fax','$hours','$mail','$site','$pays','$province','$ville','$adresse','$prix','$cadastre','$superfh','$hall','$salon','$comment','$date','1','$obsol','$url_screen')");
echo"<br><center>"._ARTADD."</center><br>";
redirect("index.php?file=Immo",2);
CloseTable();
}
///------------------------------------------
switch($op) {
case "index":
index();
break;
case "test":
test($pays,$province,$ville);
break;
case "add":
add($pseudo,$tel,$fax,$hours,$mail,$site,$pays,$province,$ville,$adresse,$prix,$cadastre,$superfh,$hall,$salon,$comment,$date,$active,$obsol,$url_file);
break;
case "do_add":
do_add($pseudo,$tel,$fax,$hours,$mail,$site,$pays,$province,$ville,$adresse,$prix,$cadastre,$superfh,$hall,$salon,$comment,$date,$active,$obsol,$url_file);
break;
default:
index();
break;
}
///-------------------------------------------
}else if(nivo_mod($ModName)==1 && $visiteur==0){opentable();echo"<br><br><center>"._USERENTRANCE."<br><br><b><a href=\"index.php?file=User&op=login_screen\">"._LOGINUSER."</a> |
<a href=\"index.php?file=User&op=reg_screen\">"._REGISTERUSER."</a></b><br><br></center>";closetable();
}else{opentable();echo"<br><br><center>"._NOENTRANCE."<br><br><a href=\"javascript:history.back()\"><b>"._BACK."</b></a><br><br></center>";closetable();}
?>