Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/02/2011, 09:34
mafyas
 
Fecha de Ingreso: febrero-2011
Mensajes: 11
Antigüedad: 13 años, 2 meses
Puntos: 0
Validar campos de formulario

Hola tengo una duda, quiero ver si en el formulario se han escrito los campos obligatorios, creo que los codigos estan bien, lo que no se es si necesito algo mas para que funcione
os dejo los codigos

</head>
<body>
<div id="wrapper" style="height:760px; width:850px; margin:auto">
<!--HEADER-->
<div id="header" style="height:50px; width:100%; background:white; margin-top:5px; margin-bottom:60px; overflow:hidden; border:1px solid black;">
<h1 style="color:black; text-align:center">Ejercicio 2</h1>
</div>
<!--FIN HEADER-->
<!--CONTENT-->
<div id="content" style="height:600px; width:100%; background:fffff; margin-top:5px; margin-bottom:5px; overflow:hidden;">
<img src="image/help-icon.png" alt="Ayuda"/>
<p style="text-align:center; font-family:italica; color:red; font-size:20px"><i>Escriba los datos para enviar el correo</i></p>

<form action="ejercicio2.php" method="post">
<table style="height:100px; margin:auto; align:center"width="65%" cellspacing="0">
<tr>
<td><b>Correo: (*)</b></td>
<td><input style="width:85%" type="text" name="correo" /> <br /></td>
</tr>
<tr>
<td><b>Nombre: (*)</b></td>
<td><input style="width:85%" type="text" name="nombre"/> <br /></td>
</tr>
<tr>
<td><b>Asunto:</b></td>
<td><input style="width:85%" type="text" name="asunto" /><br/></td>
</tr>
<tr>
<td valign="top"><b>Texto:</b></td>
<td><textarea rows="10" cols="47" type="text" name="texto"></textarea><br /></td>
</tr>
<tr>
<td></td>
<td><input style="text-align:center" type="submit" value="Enviar correo"></input></td>
</tr>
</table>
</form>
</div>
</body>
</html>


y el php

<?php
$correo = $_POST["correo"];
$nombre = $_POST["nombre"];
$asunto = $_POST["asunto"];

if(&correo =="" || $nombre =="" || &asunto =="")
echo "Deber de completar los campos (*)";

?>

lo que me aparece es la pagina ejemplo2.php en blanco