IT.COM

PHP Help

Spaceship Spaceship
Watch

DanBingham

Top Member
Impact
3,133
Hi Folks,

I have just created a new contact.php form for use on one of our domain landers - see here: http://bucketboats.com

The form captures the data, and successfully sends this to the destination email, however, I can't seem to fix the 'error' message that appears once you click the 'send message' button?

Do i need to make a slight alteration to the script below?

<?php
$myemail = "[email protected]";

$yourname = check_input($_POST['name'], "Enter your name");
$email = check_input($_POST['email']);
$comments = check_input($_POST['offer'], "Offer Details");
$website = check_input($_POST['website']);

if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}

if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}

$message = "Hello!

Your contact form has been submitted by:

Name: $yourname
E-mail: $email
Offer Details: $comments

End of message
";

mail($myemail, $ubject, $message);

header('Location: thanks.htm');
exit();

function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}

function show_error($myError)
{
?>
<html>
<body>

<b>Please correct the following error:</b><br />
<?php echo $myError; ?>

</body>
</html>
<?php
exit();
}
?>

Any help would be appreciated.

Cheers,

Dan
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Open main.js in Notepad, find the row "
$('.contact-notif').show().append('<label class="loading-contact">Please wait</label>');" and delete pleasewait text. Save as .js

Regarding spam question - use a human-friendly bot-unfriendly test question, or add field that only bots can see and fill in.
 
Last edited:
1
•••
Ok, I have now changed the contact.php script, and it seems to have solved the problem. What additional script can I add in with regards to spam/protecting customer data? The new script is below:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['offer'];
$formcontent="From: $name \n email: $email \n Message: $message";
$recipient = "[email protected]";
$subject = "BucketBoats Inquiry";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>

A few ways to stop spam(bots) - invisible text field in the form that filters; recaptcha v2; older version of captcha (outdated imo)
 
1
•••
Your problem is not clear... The domain you linked points to bodis contact form.
What is the problem?
Please copy / paste HTML markup and php code, better in a code snippet.
It's unreadable.
Please explain the problem.
 
0
•••
Apologies, my error.

Try here (a temporary site address)
http://bucketboats-com.stackstaging.com/

The form captures the data and successfully sends this to my email (the destination email). My question is how do I tweek the current script to get rid of the 'please wait' text once the 'send message' button is clicked?


Capture.JPG
 
0
•••
Ok, I have now changed the contact.php script, and it seems to have solved the problem. What additional script can I add in with regards to spam/protecting customer data? The new script is below:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['offer'];
$formcontent="From: $name \n email: $email \n Message: $message";
$recipient = "[email protected]";
$subject = "BucketBoats Inquiry";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
 
Last edited:
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back