php mail form field not sending

on this page http://www.webauthorsgroup.com/contacform/contact.html, this form will send all the fields except for the “website” field which I added, but if I test it, the website field is “blank” or doesn’t get sent via the following form:

[embed=425,349] //check $_POST vars are set, exit if any missing
if(!isset($_POST[“userName”]) || !isset($_POST[“userEmail”]) || !isset($_POST[“userPhone”]) || !isset($_POST[“userMessage”]))
{
$output = json_encode(array(‘type’=>‘error’, ‘text’ => ‘Input fields are empty!’));
die($output);
}

//Sanitize input data using PHP filter_var().
$user_Name        = filter_var($_POST["userName"], FILTER_SANITIZE_STRING);
$user_Email       = filter_var($_POST["userEmail"], FILTER_SANITIZE_EMAIL);
$user_Phone       = filter_var($_POST["userPhone"], FILTER_SANITIZE_STRING);
$user_Message     = filter_var($_POST["userMessage"], FILTER_SANITIZE_STRING);

//additional php validation
if(strlen($user_Name)<4) // If length is less than 4 it will throw an HTTP error.
{
	$output = json_encode(array('type'=>'error', 'text' => 'Name is too short or empty!'));
	die($output);
}
if(!filter_var($user_Email, FILTER_VALIDATE_EMAIL)) //email validation
{
	$output = json_encode(array('type'=>'error', 'text' => 'Please enter a valid email!'));
	die($output);
}
if(!is_numeric($user_Phone)) //check entered data is numbers
{
	$output = json_encode(array('type'=>'error', 'text' => 'Only numbers allowed in phone field'));
	die($output);
}
if(strlen($user_Message)<5) //check emtpy message
{
	$output = json_encode(array('type'=>'error', 'text' => 'Too short message! Please enter something.'));
	die($output);
}

//proceed with PHP email.
$headers = 'From: '.$user_Email.'' . "\r\n" .
'Reply-To: '.$user_Email.'' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

$sentMail = @mail($to_Email, $subject, $user_Message, $user_Website .'  -'.$user_Name, $headers);

if(!$sentMail)
{
	$output = json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.'));
	die($output);
}else{
	$output = json_encode(array('type'=>'message', 'text' => 'Thank you '.$user_Name .'. We will be in contact with you.'));
	die($output);
}

}
?>[/embed]

Is there a piece of code I’m missing or not entering correctly? (kind of a “newbie” at php).

Thanks!

This thread was marked as solved… Did you figure out your error or was it marked solved by accident?
Normally, you would post a solution or at least explain which lines the error was in so the next person
who has this problem can check their code against yours.

Either way, good you figured it out!

I was looking at the code you posted and your contact form, it doesn’t match…

So you most likely solved it on your own.

please accept my apologies for not posting the resolution…since it was never resolved, I decided to remove it from the form for simplicity purposes. I may decide down the road to incorporate it, but for now, It functions without the added URL field.

I do thank everyone!

Sponsor our Newsletter | Privacy Policy | Terms of Service