My contact form has stopped working

  • Thread starter OnlineMenusCornwall
  • Start date
O

OnlineMenusCornwall

I'm not sure how or why but since transferring hosts, my contact form no longer works properly.

It still sends the email with the correct subject title and who the email is from but the contents of the form are not displayed in the email.

Any ideas why this could happen?
 
F

Faevilangel

Not all web hosts are the same as there are so many different server settings, so it would be a case of checking the coding and making amendments to the code to make it work.

Is the website on a cms (wordpress / joomla) or just basic html php / asap?
 
Upvote 0
O

OnlineMenusCornwall

I'm not sure, I've just transferred to Vidahost and it's a PHP contact form.

<?php
// Pick up the form data and assign it to variables
$name = $_POST['name'];
$email = $_POST['email'];
$topic = $_POST['topic'];
$comments = $_POST['comments'];

// Build the email (replace the address in the $to section with your own)
$to = '[email protected]';
$subject = "Enquiry via Online Menus Cornwall $topic";
$message = "$yourname emailed you from $companyname on $contactnumber or $mobilenumber";
$headers = "From: $email";

// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);

// Redirect
header("Location: thanks.htm");

This is the code I have been using for a long time, so nothing's changed there.
 
Upvote 0
O

OnlineMenusCornwall

Yes, that's the right website and I got your email but not the actual information you entered, other than your email address.

This is what I've been getting as the actual message.

emailed you from on or

Instead of...

JOE BLOGGS emailed you from JOE BLOGGS COMPANY on 01234 567890 or 07123 456789

The email comes from the senders address and the subject title shows properly, just the message is wrong.
 
Upvote 0

LicensedToTrade

Free Member
Nov 7, 2009
6,312
2,133
Suffolk
Yes, that's the right website and I got your email but not the actual information you entered, other than your email address.

The email comes from the senders address and the subject title shows properly, just the message is wrong.

It never actually comes from the sender's email address, the header simple makes it appear as though it does, the reality is that it is coming from your own mail server...but this is not relevant and I'm waffling! :D

Anyway, it would seem that your host transfer has certainly unsettled the form process somewhat, as Gareth says not all hosts have the exact same root layout so transfered scripts will not always be preserved and function correctly.

If you installed the script yourself then my advice would be to start from scratch on the contact page and do it again.
 
Upvote 0
O

OnlineMenusCornwall

I think I borrowed the PHP code from the interweb, so I'm not sure I can rewrite it to fix the problem. I suppose I could find more code but other than trial and error, I'm not sure how I can get it working again.
 
Upvote 0
can you rebuild the form using this method:

Contact Us Page (with form on)
form action goes to takeform.php
then it goes to sendmail.php

so you have 2 php pages doing the work

probably not very secure but a temporary fix.
 
Upvote 0

LicensedToTrade

Free Member
Nov 7, 2009
6,312
2,133
Suffolk
can you rebuild the form using this method:

Contact Us Page (with form on)
form action goes to takeform.php
then it goes to sendmail.php

so you have 2 php pages doing the work

probably not very secure but a temporary fix.

No real reason to add a second php file, particularly as the current one is peroforming correctly. This is currently a three file set-up (that could be achieved in one page) at the moment there is the html page that contains the input fields, a .php file that calls on those fields and sends the data off to the predetermined email address, and then there is the notification file which is where the user is sent to after they have completed the form to let them know that it was successfully sent.

To the OP, is it possible that you sourced the script from here... http://www.digital-web.com/articles/bulletproof_contact_form_with_php/ ?

You could either cross reference their code against yours for any variations (apart from your own customisation) OR you could use it and start from scratch.

If you do start from scratch can I recommend a script that combats spam bots? Perhaps something with a captcha form.
 
  • Like
Reactions: OnlineMenusCornwall
Upvote 0
F

Faevilangel

It seems like the following variables haven't been set

$yourname
$companyname
$contactnumber
$mobilenumber

Add this to the top of the file

Code:
$yourname = $_POST['yourname'];
$companyname = $_POST['companyname'];
$contactnumber = $_POST['contactnumber'];
$mobilenumber = $_POST['mobnumber'];
 
Last edited by a moderator:
  • Like
Reactions: OnlineMenusCornwall
Upvote 0
O

OnlineMenusCornwall

Yeh, that looks familiar. I've have to play around with it again but for now I've used an online form creator. Not ideal, but at least it's working for the time being.

Thanks for your help :D

No real reason to add a second php file, particularly as the current one is peroforming correctly. This is currently a three file set-up (that could be achieved in one page) at the moment there is the html page that contains the input fields, a .php file that calls on those fields and sends the data off to the predetermined email address, and then there is the notification file which is where the user is sent to after they have completed the form to let them know that it was successfully sent.

To the OP, is it possible that you sourced the script from here... http://www.digital-web.com/articles/bulletproof_contact_form_with_php/ ?

You could either cross reference their code against yours for any variations (apart from your own customisation) OR you could use it and start from scratch.

If you do start from scratch can I recommend a script that combats spam bots? Perhaps something with a captcha form.
 
Upvote 0
O

OnlineMenusCornwall

I tried this but couldn't get it working. It's getting late so I've just bodged it for now :D

It seems like the following variables haven't been set

$yourname
$companyname
$contactnumber
$mobilenumber

Add this to the top of the file

Code:
$yourname = $_POST['yourname'];
$companyname = $_POST['companyname'];
$contactnumber = $_POST['contactnumber'];
$mobilenumber = $_POST['mobnumber'];
 
Upvote 0

Latest Articles