Highlighted

Contact form not working/PHP

New Here ,
May 23, 2019

Copy link to clipboard

Copied

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! 

Views

325

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Contact form not working/PHP

New Here ,
May 23, 2019

Copy link to clipboard

Copied

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! 

Views

326

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 23, 2019 0
Adobe Community Professional ,
May 23, 2019

Copy link to clipboard

Copied

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, ACP - www.webspectrum.co.uk

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2019 1
Adobe Community Professional ,
May 23, 2019

Copy link to clipboard

Copied

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, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2019 0
Adobe Community Professional ,
May 23, 2019

Copy link to clipboard

Copied

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, ACP - www.webspectrum.co.uk

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 23, 2019 1
New Here ,
May 24, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 24, 2019 0
Adobe Community Professional ,
May 24, 2019

Copy link to clipboard

Copied

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, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 24, 2019 0
New Here ,
May 26, 2019

Copy link to clipboard

Copied

Well I've checked the settings and the hosting service allows PHP up to the latest version

I did see your tutorial and ran that and it works fine, the email is received – you can see the test page here just to check for yourself

Bootstrap Form and PHP Script

When applied to the original index page though, with the PHP saved in a different file, the message doesn't get sent, and the redirect to the thank you page doesn't work though, so I'm missing something somewhere

Interestingly, with regard to the NateMail PHP mentioned earlier, that was used on a site I did years ago, that's still archived online and the form still works now Contact information and directions to Edibles 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 26, 2019 0
Adobe Community Professional ,
May 26, 2019

Copy link to clipboard

Copied

hourtayter  wrote

I did see your tutorial and ran that and it works fine, the email is received – you can see the test page here just to check for yourself

Bootstrap Form and PHP Script

When applied to the original index page though, with the PHP saved in a different file, the message doesn't get sent, and the redirect to the thank you page doesn't work though, so I'm missing something somewhere

My tutorial was written to be an all in one solution.  The  PHP script, HTML form, validation, success and error reporting are all performed on one page.  No other documents required.  It won't work any other way without a total re-write.  Sorry.

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 26, 2019 0