image
Inicio » PHP » Biblioteca de Código PHP » Biblioteca de código

Utilidades

Form Mail

Envia el contenido de un formulario por email.

Fecha: 02/02/2002
Puntación: [3.6/5] Puntuar
  Volver Volver

Código

<HTML><BODY BGCOLOR=FFFFFF>
<?php
$to = 'youremail@yourhost.www';
$from = 'autoreply@yourhost.www';

//Check if we have something POSTed by the form.
if (isset($HTTP_POST_VARS)){
//Start with an empty body for the mail message
$body = '';
//Iterate through all the POSTed variables, and add them to the message body.
while (list($key, $value) = each($HTTP_POST_VARS)){
$body .= $key . ' = ' . $value . "
";
}
//Build up some nice From/Reply Headers
$headers = "From: $from
";
$headers .= "Reply-To: $from
";
//Mail the message out.
//Requires setting php3.ini sendmail path as per instructions
$success = mail($to, "Posted " . date("m/d/Y"), $body, $headers);
//Always check return codes from functions.
if ($success){
echo "<B><CENTER>Thank you for your input</CENTER></B>
";
}
else{
echo "<CENTER><B>Internal Error</B>: Your input was unprocessed.<BR>Contact $from</CENTER>
";
}
}
?>
<FORM ACTION=formmail.php METHOD=POST>
<INPUT NAME=sample><BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY></HTML>



  Volver Volver







Comparte



 
Valid HTML 4.01!
Última modificación:31 de Agosto de 2017. Spain - Espa�a.
© 1998-2004 por . Todos los derechos reservados.