Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] validar campo de texto, lado servidor

Estas en el tema de validar campo de texto, lado servidor en el foro de PHP en Foros del Web. entrar.php <html> <form method=post action=v.php> <head> <title> prueba </title> </head> <body> <input type=text name=textbox1> <input type=submit value=ingresar> </body> </from> </html> v.php <?php extract($_POST, EXTR_SKIP|EXTR_PREFIX_ALL|EXTR_REFS, 'f'); ...
  #1 (permalink)  
Antiguo 08/12/2014, 07:57
 
Fecha de Ingreso: noviembre-2014
Ubicación: peru-lima
Mensajes: 32
Antigüedad: 9 años, 4 meses
Puntos: 2
validar campo de texto, lado servidor

entrar.php

<html>
<form method=post action=v.php>
<head>
<title> prueba </title>
</head>
<body>
<input type=text name=textbox1>
<input type=submit value=ingresar>
</body>
</from>
</html>

v.php

<?php
extract($_POST, EXTR_SKIP|EXTR_PREFIX_ALL|EXTR_REFS, 'f');
$t = $f_textbox1;

if ($comprobar == ""){
$msj="llenar campos";
header("Location:entrar.php");
}
else{
echo $t;
}
?>
header puede enviar a otro.php (no puedo mostrar $msj)pero no volver a entrar.php, esa es mi problema
y si llega a ir a entrar.php mostrar la variable $msj abajo del boton o a la derecha de la caja de texto


---gracias---
  #2 (permalink)  
Antiguo 08/12/2014, 12:05
Avatar de ArturoGallegos
Moderador
 
Fecha de Ingreso: febrero-2008
Ubicación: Morelia, México
Mensajes: 6.774
Antigüedad: 16 años, 1 mes
Puntos: 1146
Respuesta: validar campo de texto, lado servidor

1 .- no uses extract() es mas fácil solo poner $_POST['textbox1']

2.- en la dirección incluye el mensaje
header("Location:entrar.php?msg=".$msg);
  #3 (permalink)  
Antiguo 09/12/2014, 08:43
 
Fecha de Ingreso: noviembre-2014
Ubicación: peru-lima
Mensajes: 32
Antigüedad: 9 años, 4 meses
Puntos: 2
Respuesta: validar campo de texto, lado servidor

solucionado --- gracias... se podra mostrar con metodo POST en bnvnd.php cambiando el codigo header("Location:bnvnd.php?comprobar=".$comprobar) ;(solo da GET)

entrar.php

<html>
<form method=post action=v.php>
<head>
<title> prueba </title>
</head>
<body>
<input type=text name=textbox1>
<?php
if (isset($_REQUEST['msg'])) {
$name = $_REQUEST['msg'];
echo $name;
} else {
$name = "";
}
?>
<input type=submit value=ingresar>
</body>
</from>
</html>
---------------------------------------------------------------------------------
v.php

<?php
$comprobar = $_POST['textbox1'];

if ($comprobar == ""){
$msg = "llenar campos";
header("Location:entrar.php?msg=".$msg);
}
else{

header("Location:bnvnd.php?comprobar=".$comprobar) ;
}
?>

--------------------------------------------------------------------------------------
bnvnd.php

<?php
$r = $_GET['comprobar'];
echo $r;
?>

Etiquetas: campo, html, lado, servidor, variable
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 11:08.