Advertisement
Guest User

contact.php

a guest
Aug 14th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="es">
  3. <head>
  4.     <meta charset="utf-8">
  5.     <title>Contacto</title>
  6.     <style>
  7.         .error{
  8.             color:red;
  9.             font-weight: bold;
  10.         }
  11.         .ok{
  12.             color:green;
  13.             font-weight: bold;
  14.         }
  15.     </style>
  16. </head>
  17. <?php
  18.     if(isset($_POST['submit'])){
  19.         if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['message'])){
  20.             $nombre=$_POST['name'];
  21.             $correo=$_POST['email'];
  22.             $mensaje=$_POST['message'];
  23.             $fp = fopen("logs.txt","a");
  24.             fwrite($fp, "Nombre: $nombre \t Correo: $correo \t Mensaje: $mensaje" . PHP_EOL);
  25.             fclose($fp);
  26.             echo '<p class="ok">Su mensaje ha sido enviado correctamente.</p>';
  27.         }else{
  28.             echo '<p class="error">No ha llenado los campos correctamente.</p>';
  29.         }
  30.     }else{
  31. ?>
  32. <body>
  33.     <center>
  34.     <h1>Formulario de contacto</h1>
  35.     <form action="contact.php" method="post">
  36.         <p>nombre: <input type="text" name="name" size="15" maxlength="40"></p>
  37.         <p>correo: <input type="text" name="email" size="15" maxlength="80"></p>
  38.         <p>mensaje: <textarea name="message"></textarea></p>
  39.         <p><input type="submit" value="Enviar" name="submit"></p>
  40.     </form>
  41.     </center>
  42. </body>
  43. </html>
  44. <?php
  45. }
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement