Skip to main content
Known Participant
May 23, 2019
Question

Contact form not working/PHP

  • May 23, 2019
  • 3 replies
  • 2564 views

Evening all hopefully I can get a bit of help here (again!) – the contact form on the website here Welcome to Merlin's Cafe  is pretty simple  but I can't get it to work correctly, though I've used the same form and PHP set up before without any trouble – so does anyone have any suggestions as to why things aren't working as they should with the form?

Or if anyone has a better form/PHP setup, especially one that can stop spam efficiently, that would be handy to know too.

Thanks in advance! 

This topic has been closed for replies.

3 replies

Legend
May 24, 2019

I found this manual for Natemail 3.0: http://www.spanishhillsdentallv.com/NateMail3_HTML/Manual%20(HTML).pdf  there was also a more advanced version called ProcessForm written by the same developer but these scipts are very, very old...

You really should look at using a more up to date form processing script, look for an ajax/php form processor with Google Recaptcha built in and then pretty much all of the work is one for you if you're not sure how to integrate Recaptcha:

PHP Form Processors Scripts - Free, commercial and open source scripts

https://codecanyon.net/category/php-scripts/forms

Paul-M - Community Expert
Known Participant
May 24, 2019

Thanks for the replies so far – basically the form redirects to a PHP page which originally used this script

<?php

$ip = $_POST['ip'];

$httpref = $_POST['httpref'];

$httpagent = $_POST['httpagent'];

$visitor = $_POST['visitor'];

$visitormail = $_POST['visitormail'];

$visitorphone = $_POST['visitorphone'];

$address1 = $_POST['address1'];

$address2 = $_POST['address2'];

$city = $_POST['city'];

$state = $_POST['state'];

$zip = $_POST['zip'];

$notes = $_POST['notes'];

if (eregi('http:', $notes)) {

die ("Do NOT try that! ! ");

}

if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))

{

echo "<h2>Use Back - Enter valid e-mail</h2>\n";

$badinput = "<h2>Your message was NOT submitted</h2>\n";

echo $badinput;

die ("Go back! ! ");

}

if(empty($Name) || empty($email) || empty($textarea)) {

echo "<h2>Use your Back button - fill in all fields, No message was sent.</h2>\n";

die ("Use back! ! ");

}

$todayis = date("l, F j, Y, g:i a") ;

$subject = Contact_from_your_webpage;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n

Message: $notes \n

From: $visitor ($Name)\n

From: $visitor ($email)\n

Additional Info : IP = $ip \n

Browser Info: $httpagent \n

Referral : $httpref \n

";

$from = "From: $visitormail\r\n";

mail("xxxxxx@xxxxxxxxxxxx", $subject, $message, $from);

//check if form was sent

if($_POST){

  $to = 'xxxxxx@xxxxxxxxxxxx';

  $subject = 'Testing HoneyPot';

  $header = "From: $name <$name>";

  $Name = $_POST['Name'];

  $email = $_POST['email'];

  $textarea = $_POST['textarea'];

  //honey pot field

  $honeypot = $_POST['firstname'];

  //check if the honeypot field is filled out. If not, send a mail.

  if( $honeypot > 1 ){

  return; //you may add code here to echo an error etc.

  }else{

  mail( $to, $subject, $message, $header );

  }

}

if($_POST['nospam_field_name'] != ''){

  echo "It appears you are a spambot! Form processing aborted";

}

else{

//process the rest of the form

}

?>

<p>

Date: <?php echo $todayis ?>

<br />

Thank You : <?php echo $Name ?> ( <?php echo $email ?> ) 

<br />

Message:<br />

<?php $notesout = str_replace("\r", "<br/>", $notes);

echo $notesout; ?>

<br />

<?php echo $ip ?>

I did realise just now that one other issue is the idea was it was supposed to redirect to a thank you page when the form was successfully sent – I did see Nancy's tutorial on forms and PHP

Nancy OShea
Community Expert
Community Expert
May 24, 2019

Posting this old script doesn't help much.  Like I said before, ask your web host what script you can use with your hosting plan.  Many require SMTP authentication now to stop bad actors from using your server as a spam relay.   

Nancy O'Shea— Product User & Community Expert
Nancy OShea
Community Expert
Community Expert
May 23, 2019

NateMail 3 PHP script has got to be about 10 years old.  I don't know if it has been updated or if it's even up to the task anymore.   Ask your web hosting provider which form-to-email scripts they recommend you use with your hosting plan.

To stop spam, use Google's reCaptcha.  It's free but you must obtain a  key from Google first.

reCAPTCHA: Easy on Humans, Hard on Bots

Nancy O'Shea— Product User & Community Expert
Legend
May 23, 2019

I would say for starters without seeing the script that you need a hidden field recipient with a value of the email address to send the form data to, either that or you need to set the recipient email address in your mailer script itself .. Which mail script is it?

Also, not an ideal set up to put an email address in a hidden form field as you would be exposing your email address to email harvesters ...

Paul-M - Community Expert