Foros del Web » Programando para Internet » PHP »

Codigo Php

Estas en el tema de Codigo Php en el foro de PHP en Foros del Web. Tengo el Siguiente Codigo de php en mi form: <head> <title>PAGINA WEB MPSM</title> </head> <body> <form name="form1" method="get" action="Untitled-1.php"> <table align="center"> <th>SISTEMA WEB MPSM</th> </table> ...
  #1 (permalink)  
Antiguo 05/07/2011, 14:54
 
Fecha de Ingreso: septiembre-2009
Mensajes: 138
Antigüedad: 14 años, 7 meses
Puntos: 3
Codigo Php

Tengo el Siguiente Codigo de php en mi form:

<head>
<title>PAGINA WEB MPSM</title>
</head>
<body>
<form name="form1" method="get" action="Untitled-1.php">
<table align="center">
<th>SISTEMA WEB MPSM</th>
</table>
<div id="Layer1">
<div id="Layer2" onClick="MM_showHideLayers('Layer6','','show','Lay er7','','hide','Layer31','','hide','Layer32','','h ide','Layer33','','hide','Layer34','','hide','Laye r8','','hide','Layer35','','hide','Layer36','','hi de','Layer37','','hide')">
<a href="#">CONTROLAR USUARIO</a></div>
<div id="Layer3" onClick="MM_showHideLayers('Layer6','','hide','Lay er7','','show','Layer31','','show','Layer32','','s how','Layer33','','show','Layer34','','show','Laye r8','','hide','Layer35','','hide','Layer36','','hi de','Layer37','','hide')">
<a href="#" >CONTROLAR ASISTENCIA</a></div>
<div id="Layer4" onClick="MM_showHideLayers('Layer6','','hide','Lay er7','','hide','Layer31','','hide','Layer32','','h ide','Layer33','','hide','Layer34','','hide','Laye r8','','show','Layer35','','show','Layer36','','sh ow','Layer37','','show')">
<a href="#">CONTROLAR ACTIVIDADES</a></div>
<div id="Layer5">
<a href="#" >ADMINISTRAR PERSONALES</a></div>
</div>
<div id="Layer6">
<div id="Layer9">Nombre:</div>
<div id="Layer10"><input type="text" name="nombre" value=<?php if(isset($_GET['nombre'])){ echo $_GET['nombre']; } ?>></div>
<div id="Layer11">Apellido:</div>
<div id="Layer12"><input type="text" name="apellido" value=<?php if(isset($_GET['apellido'])){ echo $_GET['apellido']; }?>></div>
<div id="Layer13">Direccion:</div>
<div id="Layer14"><input type="text" name="direcc" value=<?php if(isset($_GET['direcc'])){echo $_GET['direcc'];}?>></div>
<div id="Layer15">Edad:</div>
<div id="Layer16"><input type="text" name="edad" value=<?php if(isset($_GET['edad'])){ echo $_GET['edad']; } ?>></div>
<div id="Layer17">Dni:</div>
<div id="Layer18"><input type="text" name="dni" value=<?php if(isset($_GET['dni'])){ echo $_GET['dni']; } ?>></div>
<div id="Layer19">Correo:</div>
<div id="Layer20"><input type="text" name="correo" value=<?php if(isset($_GET['correo'])){ echo $_GET['correo'];}?>></div>
<div id="Layer21" align="center"><input type="submit" name="Submit" value="Insertar" onClick="alerta()"></div>
<div id="Layer22" align="center"><input type="submit" name="Submit2" value="Mostrar"></div>
<div id="Layer23" align="center"><input type="submit" name="Submit3" value="Eliminar"></div>
<div id="Layer24" align="center"><input type="submit" name="Submit4" value="Modificar"></div>
<br><br><br><br><br><br><br><br><br><br><br><br>

<?php
if(isset($_GET["Submit2"]))
{
$sel="select * from usuario";
$con=mysql_query($sel);
echo "<table id=tabla width=700 border=1 align=center>";
echo "<tr id=celdas name=celdas align=center width=700>";
echo "<td width=700>Id</td>";
echo "<td width=700>Nombre</td>";
echo "<td width=700>Apellido</td>";
echo "<td width=700>Direccion</td>";
echo "<td width=700>Edad</td>";
echo "<td width=700 name=id>Dni</td>";
echo "<td width=700>Correo</td>";
echo "<td width=700>Seleccion</td>";
echo "</tr></table>";
while($ins=mysql_fetch_array($con))
{
//onclick=alert(this.getElementsByTagName('td')[0].innerHTML)"
echo "<table id=tabla width=700 border=1 align=center>";
echo "<tr id=celdas name=celdas align=center width=350 onmouseover=this.style.cursor='hand'>";
echo "<td width=700 name=id>";
echo $ins[0];
echo "</td>";
echo "<td width=700>";
echo $ins[1];
echo "</td>";
echo "<td width=700>";
echo $ins[2];
echo "</td>";
echo "<td width=700>";
echo $ins[3];
echo "</td>";
echo "<td width=700>";
echo $ins[4];
echo "</td>";
echo "<td width=700>";
echo $ins[5];
echo "</td>";
echo "<td width=700>";
echo $ins[6];
echo "</td>";
echo "<td width=700>";
echo "<input type=checkbox name=caja value=$ins[0]>";
echo "</input>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
}
?>
</div>

<div id="Layer7">
<div id="Layer31">Nombre:</div>
<div id="Layer32"><input type="text" name="textfield"></div>
<div id="Layer33">Fecha:</div>
<div id="Layer34"><input type="text" name="textfield2" id="calendar2_container"></div>
</div>

<div id="Layer8">
<div id="Layer35">Nombre Archivo:</div>
<div id="Layer36"><input name="archivos" type="file" id="archivos"></div>
<div id="Layer37" align="center"><input type="submit" name="Submit5" value="Subir"></div>
</div>

</form>
<?php
if(isset($_GET["Submit"]))

{
$consulta_insert="insert into usuario(Id,Nombre,Apellido,Direccion,Edad,Dni,Corr eo)values('','".$_GET['nombre']."','".$_GET[ 'apellido']."','".$_GET['direcc']."','".$_GET['edad']."','".$_GET['dni']."','".$_GET['correo']."')";
$consulta_ejecutar=mysql_query($consulta_insert) ;
}
?>


<?php
if(isset($_GET["Submit3"]))
{
if(isset($_REQUEST['caja']))
{
$cajavalor=$_REQUEST['caja'];
$eli="delete from usuario where id=$cajavalor";
$eje=mysql_query($eli);
}
}
?>


<?php
if(isset($_GET["Submit4"]))

{
if(isset($_REQUEST['caja']))
{
$cajavalor=$_REQUEST['caja'];
$eli="update usuario set Nombre='".$_GET['nombre']."',Apellido='".$_GET['apellido']."',Direccion='".$_GET['direcc']."',Edad='".$_GET['edad']."',Dni='".$_GET['dni']."',Coe='".$_GET['correo']."' where Id=$cajavalor";
$eje=mysql_query($eli);
}
}
?>
</body>
</html>



Como hago para que no se cargue toda la pagina.
  #2 (permalink)  
Antiguo 05/07/2011, 15:31
 
Fecha de Ingreso: noviembre-2007
Mensajes: 66
Antigüedad: 16 años, 5 meses
Puntos: 0
Respuesta: Codigo Php

Hola podrias ocupar etapas para redireccionar al mismo php lo que quieras cargar

Con esta funcion te entrega la rura del archivo

$_SERVER['PHP_SELF']


si ocupas JS para redireccionar seria

colocas un input oculto con la direccion


<input type='hidden' id='ruta' value='$_SERVER['PHP_SELF'].'>";


luego con un en JS tomas la ruta

ruta=document.getElementById('ruta').value;

luego con href redireccionas al mismo php


location.href=ruta+'?etapa=1&fecha='+fecha+'&motiv o='+motivo;


OJO si llamas en el href las variables === a las de php no tines que tomarlas con GET solo nombrarlas


Código PHP:

<?

    
if($etapa==1)
    {
        echo 
"lo logre<br>";
        echo 
$letras;
        
    }
    if(
$etapa!=1)
    echo 
"<form name='ingreso' method='post'>
    
        <input type='text' id='letras'>
        
        <input type='button' id='btnSave' value='Ingresar'>
    
    
    
    
    <input type='hidden' id='ruta' value='"
.$_SERVER['PHP_SELF']."'>
    
    </form>
    
    <script languaje='javascript'>


/* Validacion de ingreso */
    
document.getElementById('btnSave').onclick=function() {

    ruta=document.getElementById('ruta').value;    
    valor=document.getElementById('letras').value;    

    location.href=ruta+'?etapa=1&letras='+valor;

}

</script>"
;    

?>
  #3 (permalink)  
Antiguo 05/07/2011, 15:52
Avatar de victor_aguilar  
Fecha de Ingreso: junio-2011
Ubicación: México DF
Mensajes: 67
Antigüedad: 12 años, 10 meses
Puntos: 10
Respuesta: Codigo Php

el metodo get lo he ocupado para pasar parámetros entre páginas con la información dentro de la barra de navegación, para pasar parámetros ocultos o que solo se actualice una parte de la información yo he ocupado el método post que responde a un evento y si no le pongo action se hace en la misma página
Salu2
__________________
"... tiene la vida un lánguido argumento que no se acaba nunca de aprender"
Joaquín Sabina
  #4 (permalink)  
Antiguo 16/07/2011, 01:37
 
Fecha de Ingreso: septiembre-2009
Mensajes: 138
Antigüedad: 14 años, 7 meses
Puntos: 3
Respuesta: Codigo Php

La Variable $etapa de donde lo saco.

Etiquetas: html, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:46.