1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
<?php $submit = !empty($_REQUEST['submit']); ?> <!DOCTYPE html> <html lang="en-GB"> <head> <meta charset="UTF-8" /> <?php if( $submit ){ ?><meta HTTP-EQUIV="Refresh" CONTENT="3; URL=" /><?php } ?> <title>Email test</title> <style type="text/css"> label{display: block;} input,textarea{margin-bottom:15px;} </style> </head> <body> <?php // Display the contact form: if( !$submit ) { ?> <form action="" method="POST" enctype="multipart/form-data"> <label>Your name</label> <input name="name" type="text" value="" size="30"/> <br/> <label>Your email</label> <input name="email" type="email" value="" size="30"/> <br/> <label>Your message</label> <textarea name="message" rows="7" cols="30"></textarea> <br/> <input name="submit" type="submit" value="Send email"/> </form> <?php } // Send the submitted data: else { $name = $_REQUEST['name']; $email = $_REQUEST['email']; $message = $_REQUEST['message']; if( empty($name) || empty($email) || empty($message) ) { ?><p>All fields are required.<br/>You will be redirected in 3 seconds.</p><?php } else { $from = "From: $name<$email>\r\nReturn-path: $email"; $subject = "Message sent using your contact form"; mail( $email/*TO*/, $subject, $message, $from ) ; ?><p>Email sent!<br/>You will be redirected in 3 seconds.</p><?php } } ?> </body> </html> |
Edit:
El visualizado de código de WP omite algunas partes del código PHP por seguridad. Desde aquí puede bajarse el fichero original: