Tengo un formulario con cuatro select dependiente que en mi red local funciona más o menos bien.
El problema ha sido que cuando he adquirido un dominio, he subido todo el código y la db. Y me lo lee bien pero no retiene la información de los ids para posteriormente grabarlos en la tabla.
¿Cómo puedo modificar código para me graben los ids en tabla?
GRACIAS
pais (
id_pais
pais
)
region (
id_reg
id_pais
region
)
provincial (
id_pro
id_pais
id_reg
provincial
)
localidad (
id_local
id_pais
id_reg
id_pro
local
)
<?php include ("../libreria/conecta.php");
$db= new base();
?>
<html>
<head>
<title>modificar direccines webs</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
$result= "SELECT * FROM direc WHERE id_w= $_GET[pas]";
$web= $db->consulta($result);
while ($w = mysql_fetch_assoc($web)) {
?>
<form action= "modi_web.php?pas=<? echo $w['id_w']; ?>" method="post">
<table width="86%" border="1">
<tr>
<td width="26%"><div align="center">País</div></td>
<td width="23%"><div align="center">Región</div></td>
<td width="29%"><div align="center">Provincia</div></td>
<td width="29%"><div align="center">Localidad</div></td>
</tr>
<tr>
<td>
<select name="s_pais" onChange="submit()" >
<? if (!isset ($_POST['s_pais']))
{
$lisp1= $db->consulta("SELECT * FROM pais WHERE id_pais= $w[id_pais]");
while ($pais = mysql_fetch_assoc($lisp1)) {
?>
<option selected value="
<? echo $pais['id_pais']; ?>"><? echo $pais['pais']; ?></option> <? } } else {
$lisp1= $db->consulta("SELECT * FROM pais WHERE id_pais= $_POST[s_pais]");
while ($pais = mysql_fetch_assoc($lisp1)) {
?>
<option selected value="
<? echo $pais['id_pais']; ?>"><? echo $pais['pais'];?></option>
<? } }
$lisp2= $db->consulta("SELECT * FROM pais");
while ($pais2 = mysql_fetch_assoc($lisp2)) { ?>
<option value="<?php echo $pais2['id_pais'] ?>"><?php echo $pais2['pais'] ?></option>
<? } ?>
</select>
</td>
<td>
<select name="s_reg" onChange="submit()" >
<? if (!isset ($_POST['s_reg']))
{
$lisp1= $db->consulta("SELECT * FROM region WHERE id_reg= $w[id_reg]");
while ($regi = mysql_fetch_assoc($lisp1)) {
?>
<option selected value="<? echo $regi['id_reg']; ?>"><? echo
$regi['region']; ?></option>
<? } } else {
$lisp1= $db->consulta("SELECT * FROM region WHERE id_reg= $_POST[s_reg]");
while ($regi = mysql_fetch_assoc($lisp1)) {
?>
<option selected value="
<? echo $regi['id_reg']; ?>"><? echo $regi['region'];} } ?></option>
<?
$lisr2= $db->consulta("SELECT * FROM region WHERE id_pais= $_POST[s_pais]");
while ($reg2 = mysql_fetch_assoc($lisr2)) {
?>
<option value="<?php echo $reg2['id_reg'] ?>"><?php echo $reg2['region'] ?></option>
<? } ?>
</select>
</td><td>
<select name="s_pro" onChange="submit()" >
<? if (!isset ($_POST['s_pro']))
{
$lisp1= $db->consulta("SELECT * FROM provincia WHERE id_pro= $w[id_pro]");
while ($prov = mysql_fetch_assoc($lisp1)) {
?>
<option selected value="
<? echo $prov['id_pro']; ?>"><? echo $prov['provincia']; ?></option>
<? } } else {
$lisp1= $db->consulta("SELECT * FROM provincia WHERE id_pro= $_POST[s_pro]");
while ($prov = mysql_fetch_assoc($lisp1)) {
?>
<option selected value="
<? echo $prov['id_pro']; ?>"><? echo $prov['provincia']; ?></option>
<?
} }
$lisp2= $db->consulta("SELECT * FROM provincia WHERE id_reg= $_POST[s_reg]");
while ($prov2 = mysql_fetch_assoc($lisp2)) {
?>
<option value="<?php echo $prov2['id_pro'] ?>"><?php echo $prov2['provincia'] ?></option>
<? } ?>
</select>
</td>
<td>
<select name="s_lo" onChange="submit()">
<? if (!isset ($_POST['s_lo']))
{
$lisp1= $db->consulta("SELECT * FROM localidad WHERE id_local= $w[id_local]");
while ($loc = mysql_fetch_assoc($lisp1)) {
?>
<option selected value="
<? echo $loc['id_local']; ?>"><? echo $loc['local']; ?></option>
<? } } else {
$lisp1= $db->consulta("SELECT * FROM localidad WHERE id_local= $_POST[s_lo]");
while ($loc = mysql_fetch_assoc($lisp1)) {
?>
<option selected value="
<? echo $loc['id_local']; ?>"><? echo $loc['local']; ?></option>
<?
} }
$lisr2= $db->consulta("SELECT * FROM localidad WHERE id_pro= $_POST[s_pro]");
while ($loc2 = mysql_fetch_assoc($lisr2)) {
?>
<option value="<?php echo $loc2['id_local']; ?>"><?php echo $loc2['local']; ?></option>
<? } ?>
</select>
</td></tr> <tr>
<td colspan="4"><div align="center">Claficación</div></td>
</tr> <tr> <td>
<? }
if (isset ($_POST["modi"]))
{
$modi="UPDATE direc SET id_pais = '$_POST[s_pais]', id_reg = '$_POST[s_reg]',
id_pro = '$_POST[s_pro]', id_local = '$_POST[s_lo]' WHERE id_w = '$_POST[id]'";
$db->consulta($modi);
echo "<meta http-equiv=\"refresh\" content=\"1\">";
}
?>
</body>
</html>