HELP! My Form2Email script has suddenly stopped working!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Yiaggi
Forum Newbie
Posts: 13
Joined: Tue Feb 17, 2009 5:12 am

HELP! My Form2Email script has suddenly stopped working!!

Post by Yiaggi »

Hi guys,

I have a real issue .....! I am not bad with PHP but am much better at editing scripts that writing them .... this has got me stumped!

I have been using the same PHP Form2Email script for a few years now. I have used it on many websites and modified it in many ways and it has never given me a problem. It is very simple to handle and edit.

Suddenly - a few days ago - the script on my website stopped working. The form was sending and displaying the "Thank You" message but no emails were being received by the client or by me. I checked the form on 8 different servers / hosting companies and am getting the same result.

I just cannot for the life of me work out why an untouched piece of PHP code which was working fine - can suddenly stop working?! I will list the code below and pray that one of you will be able to see the problem? If anyone can answer why a piece of code can magically stop working that would be great!

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

<?php
function treat_submission()
{
	$user = $_POST['first'];	
	$email = $_POST['email']; 
	$last = $_POST['last'];
	$phone = $_POST['phone'];
	$comments = $_POST['comments'];
	$my_email = "myemail@mydomain.com"; 	

//	MESSAGE TO ADMIN:
	$headers = "To: ".$my_email. "\r\n";
	$headers .= "From: ".$email. "\r\n";
	$subject = "Form submitted via my website";
	$msg = "".$user." ".$last." has submitted a form via the my website\r\n\r\n"; 
	$msg.= "Email - ".$email."\r\n\r\n"; 
	$msg.= "Phone - ".$phone."\r\n\r\n";
	$msg.= "Comments - ".$comments."\r\n\r\n";
	mail($my_email, $subject, $msg, $headers);
// MESSAGE TO VISITOR:
	$headers = "To: ".$email. "\r\n"; 
	$headers .= "From: ".$my_email. "\r\n";
	$headers .= "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
	$subject = "Thank you for your interest in my website.";
	$msg = "
<html>
<head>
<title>Thank You! </title>
</head>
<body>
<p>This is an automated response from me.
<br><br>
Your details have been forwarded to me blah blah blah. 
<br><br>
We plan to be back to you quickly, but certainly within 24 hours during normal circumstances. 
<br><br>
Kind Regards,
<br><br>
Me 

</p>
</body>
</html>
";
mail($email,$subject,$msg,$headers);
	}
?>
</head>
<body>
<?php
	if (isset($_POST['submit']))
		echo (treat_submission($_POST));
		
	else
		echo ("<p align=\"center\">The form has not been received.</p>");
?>
<div>
<center>
<p><b>Thank you <?php print stripslashes($_REQUEST['first']); ?></b>
    <br>
  </p>
<p>Your request has been submitted to me.</p>
<p>We will respond as soon as possible. </p>
<p><a href="http://www.mywebsite.com">Click here to return to our home page</a></p>
<p>&nbsp;</p>
</center>
</div>



</body>
</html>

If any of you can help that would be amazing - this is majorly ruining my day! lol

:banghead:
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: HELP! My Form2Email script has suddenly stopped working!

Post by getmizanur »

first check if your web host provider has disabled mail function

Code: Select all

<?php
print_r(ini_get('disable_funcitons'));
and post your result here
Yiaggi
Forum Newbie
Posts: 13
Joined: Tue Feb 17, 2009 5:12 am

Re: HELP! My Form2Email script has suddenly stopped working!

Post by Yiaggi »

thanks mate.

When i run this script nothing happens!?

The fail is happening on all servers and all hosting companies - even if mine was disabled it surely wouldn't explain why they have all suddenly stopped working?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: HELP! My Form2Email script has suddenly stopped working!

Post by Jonah Bron »

@getmizanur made a typo, it should be:

Code: Select all

<?php
print_r(ini_get('disable_functions'));
Yiaggi
Forum Newbie
Posts: 13
Joined: Tue Feb 17, 2009 5:12 am

Re: HELP! My Form2Email script has suddenly stopped working!

Post by Yiaggi »

Agggghhhh!

Same result! Thanks for your email though ....

I think I am obviously running this script wrong because i'm getting no output what-so-ever!

This is getting me down .............! :(
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: HELP! My Form2Email script has suddenly stopped working!

Post by getmizanur »

set your php to output error messages

Code: Select all

<?php
ini_set('display_errors', 1);
or execute your php file using command line on your shell(linux)/cmd(windows). you should see errors and warning messages.

...post your errors here
Yiaggi
Forum Newbie
Posts: 13
Joined: Tue Feb 17, 2009 5:12 am

Re: HELP! My Form2Email script has suddenly stopped working!

Post by Yiaggi »

Sorry mate .... you can obviously tell I am a beginner at PHP! I am much better with Javascript but PHP often baffles me! Part of the reason this sucks so much is that it was all working so well before - now there is a major problem and its taking me days to sort out! I guess I need it explaining like an 8 year old because I am getting no results at all!

To clarify - I have added your above script to my FormToEmail script and am getting no output. I have also tried running this script on its own. . . . . . I guess I am clearly missing the point!?
Post Reply