Jump to content

danbingham

Members
  • Content count

    19
  • Joined

  • Last visited

  1. Hi Folks, I am using the PHP Contact Script below for one of our contact forms, however, we are getting alot of spam emails. What can i add into this code to prevent spam? <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['offer']; $formcontent="From: $name \n Email: $email \n Offer: $message"; $recipient = "dan@definitelydomains.com"; $subject = "CookeryClubs Inquiry"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!"; ?> Any help would be appreciated. Dan
  2. Contact Form Help

    Hi Folks, I have just created a new contact.php form for use on one of our domain landers - see here: http://bucketboats-com.stackstaging.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 /* Set e-mail recipient */ $myemail = "dan@definitelydomains.com"; /* Check all form inputs using check_input function */ $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 e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); } /* If URL is not valid set $website to empty */ if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website)) { $website = ''; } /* Let's prepare the message for the e-mail */ $message = "Hello! Your contact form has been submitted by: Name: $yourname E-mail: $email Offer Details: $comments End of message "; /* Send the message using mail() function */ mail($myemail, $ubject, $message); /* Redirect visitor to the thank you page */ header('Location: thanks.htm'); exit(); /* Functions we used */ 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
  3. Image Help

    I assume i will need to create an 'img' file and upload this to the server?
  4. Image Help

    Hi Folks, I am trying to get the image displayed on the following - page: http://definitelydomains-com.stackstaging.com/ I was wondering if someone could take a quick look at the script below for me and suggest a tweek? I need to add in the .png file. Still learning! Thanks, Dan _____ <div class="row"> <div class="col-lg-3 col-md-4 col-sm-6 portfolio-item"> <div class="card h-100"> <a href="#"><img class="card-img-top img-fluid" src="http://placehold.it/700x400" alt=""></a> <div class="card-block"> <h5 class="card-title"><a href="#">DroneKnockouts</a></h5>
  5. PHP Form Help

    It's still not capturing the data. You can now submit the form but nothing happens after that?
  6. PHP Form Help

    <?php if(isset($_POST['email'])) { echo 'email is set'; } if(isset($_POST['name'])) { echo 'name is set'; } if(isset($_POST['offer'])) { echo 'offer is set'; } exit(); $email = $_POST['email']."\r\n"; $name = $_POST['name']."\r\n"; $offer = $_POST['offer']."\r\n"; $message_date = date('d-m-Y H:i'); //-- your txt file name $file = 'customer_message.txt';
  7. PHP Form Help

    Changing the customer_message.txt file as below...
  8. PHP Form Help

    Nope, still shows error?
  9. PHP Form Help

    Just says error at the bottom of the form once you click send message
  10. PHP Form Help

    Thanks. This is all quite new to me so struggling a little in what I need to do to get this sorted. Not sure what you mean by honeypot, or sanitizing the data? Can you recommend any simple tweets I need to make? Thanks for the comments so far. Dan
  11. PHP Form Help

    What do I need to do to change this in the current script?
  12. PHP Form Help

    Hi, Thanks for your reply. Once a user enters the data and hits the send message, it displays error. No data is captured, or received at the destination email. I wasn't sure if I'm missing something, or the current script needs tweeking? Thanks, Dan
  13. PHP Form Help

    Hi Folks, I am using a modal form and im having some issues in getting the form to send data. See here - http://bucketboats.com. The contact script I am using is as follows - <?php $ToEmail = 'dan@definitelydomains.com'; $EmailSubject = 'BucketBoats'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Offer: ".nl2br($_POST["offer"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> The form setup is contained within the main index.html, and i have created a separate contact.php file where the above contact script is located. Is something wrong with this? Do I need to add anything else? I also have another document titled customer_message.txt which includes the following: <?php if(isset($_POST['email']) && isset($_POST['name']) && isset($_POST['offer'])){ $name = $_POST['name']."\r\n"; $email = $_POST['email']."\r\n"; $offer = $_POST['offer']."\r\n"; $message_date = date('d-m-Y H:i'); //-- your txt file name $file = 'customer_message.txt'; //-- read the txt's content $message = file_get_contents($file); //-- add new message to txt file $message .= "\r\n**** Message Date : ".$message_date." ****\r\n"; $message .= "Name : ".$name; $message .= "Email : ".$email; $message .= "Offer : ".$offer; $message .= "**** End Of Message ****\r\n"; //-- write message file_put_contents($file,$message); //-- send success message echo true; } else{ //-- send error message echo false; } ?> Any help would be appreciated. Dan
  14. Contact Form Help

    Hi Folks, I have form set up here - http;/drivingsupercars.com. When a user 'sends the form' it displays error, and I am not sure exactly why this is. The data is captured, and I am not sure if there is something i need to do to tweak the contact script. The current script is as below: <?php $ToEmail = 'dan@definitelydomains.com'; $EmailSubject = 'DrivingSupercars'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Offer: ".nl2br($_POST["offer"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> Any ideas? Cheers, Dan
  15. Contact Form Help

    Thank you - I will check this out. I have added a simple script in the meantime which seems to have worked to a degree. I am now able to receive the email once someone hits 'Send message', but how do i alter this script to include additional comments? The amended script i am using is below - <?php $ToEmail = 'dan@definitelydomains.com'; $EmailSubject = 'DrivingSupercars'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Offer Inquiry: ".nl2br($_POST["offer_inquiry"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?>
×