Page 1 of 1

[Solved]Confused??

Posted: Sun Feb 18, 2007 1:27 pm
by Gimpy
Ok, I cant understand why this isnt doing anything, maybe some one can point me in the right direction to help fix this.

When it tries to send it doesnt give me a confirmation and/or a error like it should..I'm still a lil green at php and maybe I just another set of eyes to look at it.

Code: Select all

///////////////////////////
//Begin Configuration
///////////////////////////

// Your email
$to = "bw.gimpy@gmail.com" . ", " ;

// Email Subject
$subject = "Game Directory filing" . "TX3Guilds.com";

// Server name, to display in the headers
$server_name = "TX3Guilds.com";

///////////////////////////
//End Configuration
///////////////////////////

if (!empty($_POST['send']) || !empty($_GET['send']))
	{
	$action = (!empty($_POST['send'])) ? $_POST['send'] : $_GET['send'];
	}
else
	{
	$action = '';
	}

$build_message = false;
if($action != "")
	{
	$build_message = true;
	$message = $_POST['games'];
	$name = $_POST['name'];
	$email = $_POST['email'];
	$website = $_POST['website'];
	//$time = time();
	$date = date("F j, Y", time());
	$headers = "MIME-Version: 1.0\r\n";
	$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
	$headers .= "From: $email\r\n";
	$headers .= "X-mailer: " . $server_name . " Server\r\n";
	}

if($build_message)
	{
/* message */
$message = "
Sender Name: $name\n 
Sender E-Mail: $email\n 
Date Sent: $date\n 
Message:\n----------------------------------------\n$message \n$website\n";

	if(mail($to, $subject, $message, $headers))
		{
		$result = "<b>Thank you</b>.<br />I will get back to you very soon.<br />";
		}
	else
		{
		$result = "Sorry: An error occured, please try again later.";
		}
	}

// Output a result Message
print $result;
Thanks in Advance,
Bryan "gimpy"

Posted: Sun Feb 18, 2007 1:31 pm
by feyd
Are you sure mail() is being called?

Posted: Sun Feb 18, 2007 1:38 pm
by Gimpy
I turned on error reporting after I read a post about the "batch email" topic after I was working on my post and this is what I recieved.

Notice: Undefined variable: result in /home/bryanund/public_html/test/tx2guildsnew/comm_file.php on line 65

line 65 is

Code: Select all

print $result;
And to be honest, I dont really think that mail is being called.

Posted: Sun Feb 18, 2007 1:43 pm
by feyd
That error would indicate it is not.

Posted: Sun Feb 18, 2007 3:25 pm
by Mordred
You will observe, that regardless of the success of mail(), $result is set, so the only possibility of $result not being set is not to enter the if($build_message)


The reason it's not working is that you don't have a $_GET or $_POST variable named 'send'. Are you sure that your form has a submit button with name="send" ?

Posted: Mon Feb 19, 2007 1:01 am
by Gimpy
That was it, thank you, I cant believe I was being complete green about that :-)

Oh well thanks for your help just need to make it where it checks for correct emails and website format.