Page 2 of 2

Re: Need help with a PHP contact form!

Posted: Thu Oct 13, 2011 7:51 pm
by Celauran
That confirms that mail() is failing. I'd open a ticket with your hosting provider.

Re: Need help with a PHP contact form!

Posted: Thu Oct 13, 2011 7:55 pm
by newguy11
Ok after i did it properly i am getting a 500 server error. It says the resource i am looking for cannot be displayed?

Re: Need help with a PHP contact form!

Posted: Thu Oct 13, 2011 7:56 pm
by Celauran
After you did what properly? What do you mean?

Re: Need help with a PHP contact form!

Posted: Thu Oct 13, 2011 7:59 pm
by newguy11
I placed the code in the wrong place

Re: Need help with a PHP contact form!

Posted: Thu Oct 13, 2011 8:00 pm
by Celauran
Post the code that resulted in the 500 error?

Re: Need help with a PHP contact form!

Posted: Thu Oct 13, 2011 8:01 pm
by newguy11

Code: Select all

<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $from = 'From: ashfordhales'; 
    $to = 'ashfordhales@gmail.com'; 
    $subject = 'Inquiry';
			
    $body = "From: $name\n E-Mail: $email\n Message:\n $message";
				
    if ($_POST['submit']) {				 
        if (mail ($to, $subject, $body, $from)) { 
	    echo '<p>Your message has been sent!</p>';
	} else { 
	    echo '<p>Something went wrong, go back and try again!</p>'; 
	} 
	$success = mail($ashfordhales@gmail.com, 'Test', 'Test Message');
var_dump($success);
    } 
?>

Re: Need help with a PHP contact form!

Posted: Thu Oct 13, 2011 8:02 pm
by Celauran

Code: Select all

$success = mail($ashfordhales@gmail.com, 'Test', 'Test Message');
This is definitely a problem. Your email address isn't a variable; it shouldn't start with $ and should be in quotes.

Let's take the form out of the equation for a minute. Create a new PHP file containing ONLY the two lines I listed earlier, and check the results of that.

Re: Need help with a PHP contact form!

Posted: Fri Oct 14, 2011 5:36 am
by newguy11
Now it replies bool(false)

Re: Need help with a PHP contact form!

Posted: Fri Oct 14, 2011 6:28 am
by Celauran
If mail() is returning FALSE, open a ticket with your hosting provider.

Re: Need help with a PHP contact form!

Posted: Fri Oct 14, 2011 7:24 am
by newguy11
Whats a ticket? and how do i do this?

Re: Need help with a PHP contact form!

Posted: Fri Oct 14, 2011 12:14 pm
by newguy11
Does anybody know how to do this?

Re: Need help with a PHP contact form!

Posted: Fri Oct 14, 2011 12:40 pm
by Celauran
Contact your hosting provider and complain that mail() isn't working.