Jump to content

Contact form doesn't work well


4554551n

Recommended Posts

Hello,

I have a problem with my mailform.php cause I don't receive any emails... I don't know what to do, what exactly should I change?

Can someone help me?

Please note that I've changed real email address into this email@email.com

<?php
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);

//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}

if (isset($_REQUEST['email']))
{//if "email" is filled out, proceed

//check if the email address is invalid
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "Invalid input";
}
else
{//send email
$name = $_REQUEST['name'];
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("email@email.com", "Subject: $subject",
$message, "From: $email" );
echo "Mail sent";
?> <meta http-equiv="REFRESH" content="3;url=index.html">  
<?php
}
}
else
{
echo 'Error, try again.';
?> <meta http-equiv="REFRESH" content="3;url=index_6.html">  <?php
}
?>

 

And here is my html code

<form action="../mailform.php" method="post">
<p>Name: <br /></p>
<p><input type="text" name="name" size="30" /></p>
<p>Email:<br /></p>
<p><input type="text" name="email" size="30" /></p>
<p>Subject:<br /></p>
<p><input type="text" name="subject" size="30" /></p>
<p>Message:<br /></p>
<p><textarea cols="50" rows="10" name="message"></textarea></p>
<p><input type="submit" value=" Send " /></p>
</form>                                                                                                   

 

Thank you.

Link to comment
Share on other sites

The From: email address must be a valid mail box at the sending mail server. You are putting the visitors entered email in as the From: address.

 

Put a valid email box at the sending mail server in as the From: address and put the visitors entered email address in as a Reply-to: address.

Link to comment
Share on other sites

You are telling me to change this

$name = $_REQUEST['name'];
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("email@email.com", "Subject: $subject",
$message, "From: $email" );

 

into

 

$name = $_REQUEST['name'];
$email = $_REQUEST['email'] ;
$reply-to = $_REQUEST['reply-to'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("email@email.com", "Subject: $subject",
$message, "From: $email", "Reply-to: $reply-to" );

 

What do u mean by "put valid email box"?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.