PHP form not sending responses

I have a website with a form on it and it just stopped sending the reply’s. I still get the saved copy in my database but I stopped getting the emails. Did something change that my syntax is not correct or did i just do it wrong and get lucky that it ever worked?

[php]<?php
$form = "






























are required
Full Name:
Phone:
City:
Email:
Questions/Comments:

";
if ($_POST['submitbtn']){
	$fullname = $_POST['fullname'];
	$email = $_POST['email'];
	$comment = $_POST['comment'];
	$phone = $_POST['phone'];
	$city = $_POST['city'];
	
	
	if ($fullname && $phone && $city && $email && $comment){
	
		if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)){
		
			mysql_query("INSERT INTO contact VALUES ('', '$fullname', '$phone', '$city', '$email', '$comment', NOW())");
		
			$webmaster = "[email protected]";
			$headers = "From: $fullname<$email>";
			$subject = "Contact Us Form from $fullname";
			$message = "$fullname\r\n$phone\r\n$city\r\n$email\r\n$comment";
			
			mail ($webmaster, $subject, $message, $headers);
			
			echo "Your message has been sent. $form";
			
		}
		else
			echo "Please enter a valid email address. $form";
	}
	else
		echo "You did not enter all required information. $form";
	
}
else
	echo "$form";
	

?>[/php]

Server info
PHP Version 5.4.43
Linux Server

Anything change on the server recently?

You should not be using mysql_ functions.
You should be using prepared statements.
You should be testing if the email was sent out.

At least you do have a list of people saved in the database.

First thanks for the help. I replied on the questions above.

PDO is what i favor. This explains it well and has the tutorial aspect to it. PDO Introduction.

To test test if mail was sent,

[php]
if ( mail($to, $sub, $msg, $header) )
// was was successfully sent
else
// mail failed to send
[/php]

Thanks,

Wish i would have known that the mail sent was that easy to test i would of had it that way already.

Sponsor our Newsletter | Privacy Policy | Terms of Service