Jump to content

Recommended Posts

I have the following quick and dirty contact form script:

 

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

if (isset($_POST['submit']))
{
	if (isset($_POST['name']) && !empty($_POST['name']))
	{
		if (preg_match("/^[A-Z\-' ]+$/i", $_POST['name']))
		{
			$name = $_POST['name'];
		}
		else { $name = false; }
	}
	else { $name = false; }

	if (isset($_POST['email']) && !empty($_POST['email']))
	{
		if (preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i", $_POST['email']))
		{
			$email = $_POST['email'];
		}
		else { $email = false; }
	}
	else { $email = false; }

	$message = htmlentities(trim($_POST['message']), ENT_QUOTES, "utf-8");
	$message = "Email Address of user: $email<br /><br />Message:<br />$message";

	$headers = 'From: mail@majorproductionsnh.com' . "\r\n" .
					'Reply-To: mail@majorproductionsnh.com' . "\r\n";

	if ($name && $email)
	{
		if (mail("*******", "Major Productions Inquery From $email", $message, $headers))
		{
			header("Location: success.html");
			exit;
		}
		else
		{ 
			header("Location: failure.html");
			exit;
		}
	}
	else
	{
		header("Location: failure.html");
		exit;
	}
}
else
{
	header("Location: home.html");
	exit;
}
?>

 

For some reason, mail is failing.  Error reporting shows nothing when I remove the header redirects.  Anything jump out as being wrong?  The headers, perhaps?  I'm thinking it's something with the shared hosting I'm on, but want to verify I didn't do something dumb before submitting a ticket to them.

Link to comment
https://forums.phpfreaks.com/topic/205998-mail-problems/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.