luespi
07-17-2009, 02:54 PM
thanks a lot for your help!
you all are really great!!
am kind of new to php
1 this script works fine but when I dont fill the email field I am supposed to be send to "noemail.html" but I just get sent to tryagain.html
2 Is the security well fixed in this email php scritp?
3 The fact that I use lots of rows blank and not, in the messages is not an issue right? That part works fine in my php5
4 if there is a server error I will be sent to servererror.html , right?
I tested that part living the "$to" part in the mail() function empty and it did sent me to servererrror.html
<?php
function spamcheck($field)
{
//--filter_var() sanitizes the e-mail address that is inserted
// --The FILTER_SANITIZE_EMAIL filter removes all forbidden e-mail characters from the inserted string $field=filter_var($field, FILTER_SANITIZE_EMAIL);
//--filter_var() validates the e-mail address that is inserted
// --The FILTER_VALIDATE_EMAIL filter validates the value of the text inserted as an e-mail address
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (isset($_REQUEST['email']))
{//this is a simple check that makes sure the email field not empty
//this is the check that uses the validation function to ensure the email address is valid
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
header( "Location: http://mydomain.com.mx/tryagain.html" );
//echo "<br><br><br><br> <center> <body bgcolor=000000> <font size=7 color=ff00> Error: <br> Ese correo no existe <br>o usted ha dejado algunos campos sin llenar <br/><br> haga click en su boton de retroceso para intentarlo de nuevo</a> </font> </center> ";
}
else
{//send email
$email = $_REQUEST['email'] ;
$messagecorto = $_REQUEST['messagecorto'] ;
$asunto = $_REQUEST['asunto'] ;
$name = $_REQUEST['name'] ;
$tel = $_REQUEST['tel'] ;
$message = "-Mensaje enviado desde su página web, con estos datos:
nombre: $name
telefono: $tel
correo: $email
mensaje:
$messagecorto
--Un mensaje de confirmacion se ha enviado al correo de la persona que envio este mensaje--
";
$message2 = "Gracias, usted nos ha enviado un mensaje desde nuestro sitio web, en breve le responderemos.
Aqui repoducimos lo que usted envio:
nombre: $name
telefono: $tel
correo: $email
mensaje:
$messagecorto
--Gracias
---SI USTED NO ENVIO ESTE MENSAJE IGNORE ESTE EMAIL. DISCULPE
";
if(mail( "prueba@mydomain.com.mx","$asunto",$message,"From: su_pagina_de_contacto@mydomain.com.mx") && mail( "$email","en mydomain.com.mx recibimos su mensaje aqui lo reproducimos",$message2,"From: prueba@mydomain.com.mx"))
{
header( "Location: http://mydomain.com.mx/gracias.html" );
}
else
{
header( "Location: http://mydomain.com.mx/servererror.html" );
}
//echo "Thank you for using our mail form! We will get in touch with you soon!";
}
}
else
{
header( "Location: http://mydomain.com.mx/noemail.html" );
//if the "email" field is not filled out the form itself will be displayed.
//echo "<form method='post' action='sendmail.php'>
// Email: <input name='email ' type='text' /><br />
// Subject: <input name='subject' type='text' /><br />
// Message:<br />
// <textarea name='message' rows='15' cols='40'>
// </textarea><br />
// <input type='submit' />
// </form>";
}
?>
you all are really great!!
am kind of new to php
1 this script works fine but when I dont fill the email field I am supposed to be send to "noemail.html" but I just get sent to tryagain.html
2 Is the security well fixed in this email php scritp?
3 The fact that I use lots of rows blank and not, in the messages is not an issue right? That part works fine in my php5
4 if there is a server error I will be sent to servererror.html , right?
I tested that part living the "$to" part in the mail() function empty and it did sent me to servererrror.html
<?php
function spamcheck($field)
{
//--filter_var() sanitizes the e-mail address that is inserted
// --The FILTER_SANITIZE_EMAIL filter removes all forbidden e-mail characters from the inserted string $field=filter_var($field, FILTER_SANITIZE_EMAIL);
//--filter_var() validates the e-mail address that is inserted
// --The FILTER_VALIDATE_EMAIL filter validates the value of the text inserted as an e-mail address
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (isset($_REQUEST['email']))
{//this is a simple check that makes sure the email field not empty
//this is the check that uses the validation function to ensure the email address is valid
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
header( "Location: http://mydomain.com.mx/tryagain.html" );
//echo "<br><br><br><br> <center> <body bgcolor=000000> <font size=7 color=ff00> Error: <br> Ese correo no existe <br>o usted ha dejado algunos campos sin llenar <br/><br> haga click en su boton de retroceso para intentarlo de nuevo</a> </font> </center> ";
}
else
{//send email
$email = $_REQUEST['email'] ;
$messagecorto = $_REQUEST['messagecorto'] ;
$asunto = $_REQUEST['asunto'] ;
$name = $_REQUEST['name'] ;
$tel = $_REQUEST['tel'] ;
$message = "-Mensaje enviado desde su página web, con estos datos:
nombre: $name
telefono: $tel
correo: $email
mensaje:
$messagecorto
--Un mensaje de confirmacion se ha enviado al correo de la persona que envio este mensaje--
";
$message2 = "Gracias, usted nos ha enviado un mensaje desde nuestro sitio web, en breve le responderemos.
Aqui repoducimos lo que usted envio:
nombre: $name
telefono: $tel
correo: $email
mensaje:
$messagecorto
--Gracias
---SI USTED NO ENVIO ESTE MENSAJE IGNORE ESTE EMAIL. DISCULPE
";
if(mail( "prueba@mydomain.com.mx","$asunto",$message,"From: su_pagina_de_contacto@mydomain.com.mx") && mail( "$email","en mydomain.com.mx recibimos su mensaje aqui lo reproducimos",$message2,"From: prueba@mydomain.com.mx"))
{
header( "Location: http://mydomain.com.mx/gracias.html" );
}
else
{
header( "Location: http://mydomain.com.mx/servererror.html" );
}
//echo "Thank you for using our mail form! We will get in touch with you soon!";
}
}
else
{
header( "Location: http://mydomain.com.mx/noemail.html" );
//if the "email" field is not filled out the form itself will be displayed.
//echo "<form method='post' action='sendmail.php'>
// Email: <input name='email ' type='text' /><br />
// Subject: <input name='subject' type='text' /><br />
// Message:<br />
// <textarea name='message' rows='15' cols='40'>
// </textarea><br />
// <input type='submit' />
// </form>";
}
?>
