Hola a todos, como andan?
Tengo un formulario de contacto en php con validación ajax y me gustaría agregar la opción "Cliquee aquí si desea recibir una copia de este email".
El archivo send.php que utilizo actualmente es el siguiente:
Código HTML:
<?php
error_reporting(E_NOTICE);
function valid_email($str)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
if($_POST['nombres']!='' && $_POST['empresa']!='' && $_POST['telefono']!='' && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && strlen($_POST['message'])>10)
{
$to = '[email protected]';
$headers = 'From: '.$_POST['email'].''. "\r\n" .
'Reply-To: '.$_POST['email'].'' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "Consulta";
$message =
"Mensaje:" . " " . htmlspecialchars($_POST['message'])
. "\r\n" . "Nombre y apellido:" . " " . htmlspecialchars($_POST['nombres'])
. "\r\n" . "Direccion:" . " " . htmlspecialchars($_POST['empresa'])
. "\r\n" . "Codigo postal:" . " " . htmlspecialchars($_POST['telefono'])
. "\r\n" . "E-mail:" . " " . htmlspecialchars($_POST['email'] );
if(mail($to, $subject, $message, $headers))
{//we show the good guy only in one case and the bad one for the rest.
echo '<p style="color:green;">Gracias '.$_POST['nombres'].'. Su consulta fue enviada.</p>';
}
else {
echo "<p>Message not sent. Please make sure you're not
running this on localhost and also that you
are allowed to run mail() function from your webserver</p>";
}
}
else {
echo '<p style="color:red;">Por favor, asegúrese de que completó todos los campos requeridos y que ingresó un email válido.</p>';
}
?>
Alguien me podría dar una mano?
Muchas gracias a todos!!