Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/09/2012, 21:41
KAKOROSAS
 
Fecha de Ingreso: enero-2004
Mensajes: 72
Antigüedad: 20 años, 4 meses
Puntos: 1
se borra lo ingresado al validar y conflico con validar y $POST

Busque y busque hice pruebas pero no pude hacerlo, por eso solicito la ayuda de ustedes...

estoy creando un test... posee 6 text (nombre, apellido ciudad, rut...etc)

el problema es que mi php al validar y encontrar alguna vacia me manda el mensaje pero me borra el contenido de todas las celdas..

como lo puedo hacer ..porfa cualquier ayuda


codigo
Código PHP:
<?php 
session_start
(); 
include_once 
"conexion.php"
?> 
<?php 
if(isset($_POST['enviar']))
{
    if(
$_POST['nombre'] == '' or $_POST['apellido'] == ''or $_POST['rut'] == '' or $_POST['ciudad'] == '')
    {
        echo 
'Por favor llene todos los campos.';
    }
        else
    {
        
$sql 'SELECT * FROM testm';
        
$rec mysql_query($sql);
         
                
$rut $_POST['rut'];
                
$codt $_POST['codt'];
                
$nombre $_POST['nombre'];
                
$apellido $_POST['apellido'];
                
$codigof $_POST['codigof'];
                
$ciudad $_POST['ciudad'];
                
$fecha $_POST['fecha'];
                
$sql "INSERT INTO testm (rut,codt,nombre,apellido,codigof,ciudad,fecha) VALUES ('$rut','$codt','$nombre','$apellido','$codigof','$ciudad','$fecha')";
                
mysql_query($sql);
 
                echo 
'su respuesta ha sido recibida';
            }
           }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test razonamientos matematicos elementales</title>
<style type="text/css">
body p strong {
    font-family: Arial, Helvetica, sans-serif;
}
body {
    font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>


<body>
<p><img src="portada1.jpg" alt="" width="1100" height="200" align="top" /></p>
<p align="center"><strong>TEST DE APTITUDES BASICAS</strong></p>
<p align="center"><strong>RAZONAMIENTOS MATEMATICOS ELEMENTALES</strong></p>
<p align="center">FORMA A</p>
<p><strong>IDENTIFICACIÓN</strong></p>
<form id="form2" name="form2" method="post" action="">
<p>&nbsp;</p>
  <table width="744" border="0">
    <tr>
      <td width="77">Nombres</td>
      <td width="158" height="48"><input name="nombre" type="text" id="nombre" value="" /></td>
      <td width="81">Apellidos</td>
      <td width="158"><p>
        <input name="apellido" type="text" id="apellido" value="" />
      </p></td>
      <td width="74">Rut</td>
      <td width="170"><label for="fecha"></label>        <input name="rut" type="text" id="rut" value="" /></td>
    </tr>
    <tr>
      <td>Fecha/hora</td>
      <td height="54"><input name="fecha" type="text" id="fecha" value="<?php
echo date("d-m-Y");
?>" /></td>
      <td>Ciudad</td>
      <td><input name="ciudad" type="text" id="ciudad" value="" /></td>
      <td>Codigo</td>
      <td><p>
        <input name="codigof" type="text" id="codigo" value="MFA" readonly="readonly" />
      </p>
    <p>
      <input name="codt" type="text" id="codt" value="codt" readonly="readonly" />
    </p></td></tr></table>

Lo otro es que tengo un php que tiene un textbox que entrega lo ingresado a otra php... hasta ahi todo bien .. pero necesito que lo deje dentro de otra casilla de texto y además valide si está en una BD mysql antes de enviar .. lo tengo asi ..Pero no me funciona

ingresar , validar y enviar

Código PHP:
<?php 
     session_start
();
    include_once 
"conexion.php";
?> 
<?php
   
    
function verificar_testm($rut,&$result)
    {
        
$sql "SELECT * FROM testm WHERE rut = '$rut'";
        
$rec mysql_query($sql);
        
$count 0;
        while(
$row mysql_fetch_object($rec))
        {
            
$count++;
            
$result $row;
        }
        if(
$count == 1)
        {
            return 
1;
        }
        else
        {
            return 
0;
        }
    }
    
    {
        if(isset(
$_POST['rut']))
        {
            if(
verificar_testm($_POST['rut'],$result) == 1)
            {
             echo 
'<div class="error">ya la hizo</div>';
            }
            else
            {
                
header("location:a_mf1.php");
                
            }
        }
 
        
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>

</head>

<body>
<form action="recibir.php" method="post"> 
Escribe tu rut: <input type="text" name="rut" size="10"> 
<input type="submit" value="Entrar"> 
</form>
 
</body>
</html>
donde recibe y necesito que la guarde en un textbox
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>
<?php 
$rut 
$_POST["rut"]; 
echo 
"Tu rut: $rut<p>"


      echo 
"Bienvenido"
 
?>
<body>
<form id="form1" name="form1" method="post" action="">
  <input type="text" name="rut" id="rut" />
</form>
</body>
</html>
muchas gracias por la ayuda