seria algo asi:
<?php function escribir($nombre,$email,$telefono,$texto) { ?> <table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0"> <tbody class="texto_contenido"> <tr> <form action="contacto.php" method="post"></form> <td style="width: 50%;" align="right">Nombre y apellidos: </td> <td style="width: 50%;"><input name="nombre" size="30" type="text"></td> </tr> <tr> <td style="width: 50%;" align="right">E-mail: </td> <td style="width: 50%;"><input name="email" size="30" type="text"></td> </tr> <tr> <td style="width: 50%;" align="right">Teléfono de contacto (opcional): </td> <td style="width: 50%;"><input name="telefono" size="15" type="text"></td> </tr> <tr> <td style="width: 50%;" align="right">Comentario: </td> <td style="width: 50%;"><textarea name="texto" cols="30" rows="5"></textarea></td> </tr> <tr> <td style="width: 50%;" align="right"></td> <td style="width: 50%;"><input name="enviar" value="Enviar" type="submit"> <input name="restablecer" value="Restablecer" type="reset"></td> </tr> </tbody> </table> <?php } function chequear($nombre,$email,$telefono,$texto) { if(!$nombre) { echo"No ha introducido el nombre"; escribir($nombre,$email,$telefono,$texto); } elseif(!$email) { echo"No ha introducido el email"; escribir($nombre,$email,$telefono,$texto); } elseif(!$texto) { echo"No ha escrito nada en el comentario"; escribir($nombre,$email,$telefono,$texto); } else { if(!eregi("^([a-z]|ñ|[A-Z]|Ñ)+( +([a-z]|ñ|[A-Z]|Ñ)+)?+$",$nombre)) { echo"No ha introducido bien el nombre"; escribir($nombre,$email,$telefono,$texto); } else resultado($nombre,$email,$telefono,$texto); } } function resultado($nombre,$email,$telefono,$texto) { $todo="Formulario página web.\n"; $todo="Nombre: ".$nombre." \n"; $todo="E-mail: ".$email."\n"; $todo="Telefono: ".$telefono." \n"; $todo="Comentario: ".$texto." \n"; mail("?????@???.es","Formulario recibido","$todo"); echo"Gracias. El mensaje se ha enviado correctamente."; } if(!$_POST['enviar']) escribir($_POST['nombre'],$_POST['email'],$_POST['telefono'],$_POST['texto']); else chequear($_POST['nombre'],$_POST['email'],$_POST['telefono'],$_POST['texto']); ?>
|