Ver Mensaje Individual
  #17 (permalink)  
Antiguo 07/04/2003, 15:28
rashid
 
Fecha de Ingreso: enero-2002
Ubicación: Perez Zeledon Costa Rica
Mensajes: 1.009
Antigüedad: 22 años, 3 meses
Puntos: 11
Cluster, es que esos $_SESSION ...etc no son mios, son de la formula tal y como venía, (no es mia, la estoy modificando), ahora, resulta que tngo entonces el problema que si vengo del menu, paso via get asi:cid=1&y=1&m=c&w=hotel1&m=c
notese entre ellos el cid. Pero ahora no me lee la info de la bd para ser editada.
Código PHP:
<?
session_start
(); // incio uso sessiones
if (isset($_SESSION['variables'])){
  
$variables=$_SESSION['variables'];
session_unregister('variables'); // Elimito variables de la sesion.
} else {
  
$variables=array();
}

?>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
   field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
   cntfield.value = maxlimit - field.value.length;
}

function show(){
    var url= "http://www.dominicalbeach.com/php/uploadForm2.php?f=1&u="+data.username.value+"&wn="+data.wname.value+"&n=1&c="+data.cid.value;
    the_window = window.open(url,'foto','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,dependent=no,screenX=0,screenY=0,width=300,height=180');
}


function check(obj){
    if (checklink() == false){
        alert('Debe indicar el link');
        data.link.focus();
        return false;
    }
...etc                
}
function checklink(){
    if (data.site.value!=""){
            if (data.link.value==""){
                return false;
            }
    }
    return true;
}
//  End -->
</script>
  <FORM METHOD="POST" ACTION="php/bdb3.php" name="data" onSubmit="return check(this)">
  <TABLE class=blkBorder cellSpacing=0 cellPadding=3 width=700 border=0>
    <TBODY>
      <TR> 
        <TD class=beigeBk colSpan=5> <DIV align=center></DIV>
          <P><B><b> 
            <?
if($e!="y"){          
              
$title "";
            
$wname=  "";
            
$tourism "";
            
$lifeestile "";
            
$surfing "";
etc.. con las otras variables.....
            
$pay "";
}

//este parametro e viene de bdb3 y lo paso para decir que e=y (editar=yes) y no hacer este select sino que reciba las variables via get    
if($e!="y"){

          if(
$m=='c'){
            
session_register("session_cid");
            
$session_cid $cid;
            @ 
$db=mysql_connect ("localhost""d""w");                
            if (!
$db){
                echo 
"Error: Could not connect to database.  Please try again later.";
            exit;
            }
            
mysql_select_db ("dombeach_dominical"); 
            
$query "Select * from `Comercials` where username ='".$session_username."' and cid=".$cid;
            
//echo $query;
            
$result mysql_query($query);
            
$row mysql_fetch_array($result);
            
$title $row["cTitle"];
            
$wname$row["wname"];
etc.. del selct..
            
$serv $row["services"];
            
$testim $row["testim"];
        }
        
        
        function 
marked($param){
         if (
$param == 1)
             echo 
"checked";
        }
        }
      
?>
            <input type="hidden" name="username" value="<? echo  $session_username ?>">
            <input type="hidden" name="cid" value="<? echo $cid?>">
            <input type="hidden" name="fillPay" value="1">
            <input type="hidden" name="pay" value="0">
            </b> 
        <TR> 
       <TR> 
        <TD colSpan=2><div align="right"><span class="SmallSpredTxt">Commercial 
            Title</span></div></TD>
        <TD colSpan=3 valign="top"> <input name="title" type="TEXT" id="title" size="40" value="<? if($e="y"){echo $variables['title'];}else{echo $title;} ?>"> 
        </TD>
      </TR>
      <TR align="left"> 
        <TD width=253 colSpan=2 align="right" valign="top"><span class="SmallSpredTxt">Web 
          Name</span><br> </TD>
        <TD colSpan=3 valign="top"><input name="wname" type="TEXT" id="wname" size="40" value="<? if($e="y"){echo $variables['wname'];}else{echo $wname;} ?>"></TD>
      </TR>
         <TD width=253 rowSpan=3> <DIV align=right class="SmallSpredTxt">Category</DIV></TD>
        <TD align=right width=127>Tourism 
          <input type="checkbox" name="tourism" value="checkbox" <? if($e="y"){if ($variables['tourism']=="checkbox"){echo " checked ";}}else{echo marked($tourism);}?>
        </TD>
        <TD align=right> <P>Real Estate 
            <input name="realestate" type="checkbox" id="realestate"value="checkbox"<? if($e="y"){if ($variables['realestate']=="checkbox"){echo " checked ";}}else{echo marked($realestate);}?> >
          </P></TD>
        <TD align="right">Other&nbsp; <input name="other" type="checkbox" id="other"value="checkbox"<? if($e="y"){if ($variables['other']=="checkbox"){echo " checked ";}}else{echo marked($other);}?> ></TD>
              </TR>
      <TR> 
      <TR> 
        <TD colSpan=2 align=right class="SmallSpredTxt">Phone 3</TD>
        <TD colSpan=3 align=left class="SmallSpredTxt"> <input name="phone3" type="TEXT" id="phone32" size="40" value="<? if($e="y"){echo $variables['phone3'];}else{echo $phone3;}?>"></TD>
      </TR>
      <TR> 
        <TD colSpan=2 align=right valign="top" class="SmallSpredTxt">Your web 
          site</TD>
        <TD colSpan=3 align="left" valign="top"> [url]http://[/url] 
          <input name="site" type="TEXT" id="site2" value="<? if($e="y"){echo $variables['site'];}else{echo $variables['site'];} ?>" size="45" > 
        </TD>
      </TR>
      <TR> 
        <TD colSpan=5 align=left><hr></TD>
      </TR>
      <TR> 
        <TD align=left>&nbsp;</TD>
        <TD colSpan=2 align=left>Remember that you gotta have a link from your 
          site to Dominical.biz. Here is where you tell us where that link is. 
        </TD>
        <TD colspan="2" align=left>&nbsp;</TD>
      </TR>
      <TR> 
        <TD colSpan=2 align=right class="SmallSpredTxt">Address of your link to 
          us:</TD>
        <TD colSpan=3><input name="link" type="TEXT" id="link" value="<? if($e="y"){echo $variables['link'];}else{echo $link;} ?>"></TD>
      </TR>
      <TR> 
        <TD width=253 colSpan=2 align=right valign="middle">Brief description 
          of your bizness 
          <DIV align=right></DIV></TD>
        <TD colSpan=3 valign="top"> <textarea name="Description" wrap="physical" cols="40" rows="7" 
onKeyDown="textCounter(document.data.Description,document.data.remLen1,80)"
onKeyUp="textCounter(document.data.Description,document.data.remLen1,80)"> <? if($e="y"){echo $variables['Description'];}else{echo $Description;} ?></textarea> 
          <br> <input readonly type="text" name="remLen1" size="3" maxlength="3" value="80">
          characters left<br> </td>
      </TR>
        <TR> 
        <TD colSpan=2 valign="middle"> <DIV align=right>Extensive description 
            of your bizness.<br>
            This will appear on your page and any area that your site is mentioned 
            here on Dominical.Biz.</DIV></TD>
        <TD colSpan=3><TEXTAREA name="bdescr" rows="15" wrap="physical" cols="70"><? if($e="y"){echo  stripslashes($variables['bdescr']);}else{echo $bdescr;} ?></TEXTAREA></TD>
      </TR>
      <TR> 
        <TD colSpan=2> <DIV align=right>Testimonials:</DIV></TD>
        <TD colSpan=3><TEXTAREA name="testim" rows="15" wrap="physical" cols="70"><? if($e="y"){echo  stripslashes($variables['testim']);}else{echo $testim;} ?></TEXTAREA></TD>
      </TR>
      <TR> 
        <TD colSpan=2> <DIV align=right>Services that you offer:</DIV></TD>
        <TD colSpan=3><TEXTAREA name="serv" rows="10" wrap="physical" cols="50"><? if($e="y"){echo  stripslashes($variables['testim']);}else{echo $serv;} ?></TEXTAREA></TD>
      </TR>
      <TR> 
        <TD colSpan=2>&nbsp;</TD>
        <TD colSpan=3> 
          </TD>
      </TR>
      <TR> 
        <TD width=253 colSpan=2>&nbsp;</TD>
        <TD colSpan=3> 
          <? 
                            
if($m=='c'){
                            if(
$e!="y"){echo "<input type='SUBMIT' value='Change' name='change'>";}
                            if(
$e!="y"){echo "<input type='SUBMIT' value='Delete' name='del'>";}
                            if(
$e!="y"){echo "<input type='SUBMIT' value='Add New' name='addnew'>";}else{echo "<input type='SUBMIT' value='Add' name='add'>";}                
    }else{
        echo 
"<input type='SUBMIT' value='Add' name='add'>";
                            }      
    </
TR>
    </
TBODY>
  </
TABLE>
</
FORM>
</
body>
</
html>
en la formula que procesa la pagina va:

Código PHP:
<?
session_start
();
$_SESSION['variables']=$_POST

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>...::::::Registro::::::...</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">

<?

        
$db=mysql_connect ("localhost""d""w");                
    if (!
$db){
        echo 
"Error: Could not connect to database.  Please try again later.";
        exit;
    }                    
    
mysql_select_db ("dombeach_dominical"); 
 

      if (isset(
$tourism)==1){
            
$tu 1;
        }else{
            
$tu 0;
            }
    
      if (isset(
$lifeestile)==1){
            
$le 1;
        }else{
            
$le 0;
            }

        
etc.. conlos ifs..
  
  if (
$HTTP_POST_VARS['add']!=""){

$title2htmlspecialchars($title);  
  
$sql =mysql_query("SELECT * FROM Comercials WHERE cTitle='$title2'"
  or die(
mysql_error()); 

if (
$sql){ 
  
$cant =mysql_num_rows($sql); 

if(
$cant >0){ 


echo  
"<script>document.location.href='/php/addprofile2.php?e=y&m=c&cn=y'</script>";       
}else{ 
    
$wname2htmlspecialchars($wname);  
  
$sql =mysql_query("SELECT * FROM Comercials WHERE cTitle='$wname'"
  or die(
mysql_error()); 
    if (
$sql){ 
      
$cant =mysql_num_rows($sql); 
    } 
    if(
$cant >0){ 
    echo  
"<script>document.location.href='/php/addprofile2.php?e=y&m=c&wn=y'</script>";       
    }else{ 
    
insert aqui// insertar
 
}
}          
</
body>
</
html>
ahora, el problema es que me regresa bien para editar en caso de que quiera meter un item con un title repetido y la formula aparece llena, pero si vengo del menu para editar la formula no me lee la info ni la despliega de la bd.

uff.