Page 1 of 1

email form help

Posted: Tue Jan 21, 2003 2:50 am
by jaimeg
I have a simple form I am learning from a book. I found out why it was not working so I corrected it to --- $_post [' variable '] --- but the message is still not printing on my email. I get the email from the sender but not the input [' variable '] they fill out.
Is their anything wrong with this code?

thank you in advance for any help

Jaime

<?

$msg = "email sent from my web site";
$msg .= "Sender's Name: $_POST['sender_name']";
$msg .= "Sender's email: $_POST['sender_email']";
$msg .= "Message: $_POST['mesage']";

$to = "my@email";
$subject = "Web Site feedback form";
$mailheaders = "From: web site\n";
$mailheaders .= "Reply-To: $sender_email\n\n";

mail ($to, $subject, $msg, $mailheaders);

?>

Posted: Tue Jan 21, 2003 2:56 am
by twigletmac
Which version of PHP is the server running? To find out just run this script:

Code: Select all

<?php
echo 'Current PHP version: ' . phpversion();
?>
What do you get if you put the following into the script that handles the information from the form:

Code: Select all

echo '<h1>'.$_POST.'</h1>';
echo '<pre>';
print_r($_POST);
echo '</pre>';

echo '<h1>'.$HTTP_POST_VARS.'</h1>';
echo '<pre>';
print_r($HTTP_POST_VARS);
echo '</pre>';
Mac

Posted: Tue Jan 21, 2003 3:04 am
by jaimeg
the website is running PHP Version 4.2.2

Where in the script do I post this code?:
echo '<h1>'.$_POST.'</h1>';
echo '<pre>';
print_r($_POST);
echo '</pre>';

echo '<h1>'.$HTTP_POST_VARS.'</h1>';
echo '<pre>';
print_r($HTTP_POST_VARS);
echo '</pre>';

before the mail () or after it?

Jaime

Posted: Tue Jan 21, 2003 3:06 am
by Skywalker
If you are running local, then maybe you have to install a mail server?

I am not sure but I think if you are running local, you have run an mail server.

Greathings Skywalker

Posted: Tue Jan 21, 2003 3:10 am
by twigletmac
Skywalker wrote:If you are running local, then maybe you have to install a mail server?

I am not sure but I think if you are running local, you have run an mail server.

Greathings Skywalker
If they are getting the mail but the variables are not being sent through then this is not the problem.

Mac

Posted: Tue Jan 21, 2003 3:12 am
by twigletmac
jaimeg wrote:the website is running PHP Version 4.2.2

Where in the script do I post this code? before the mail () or after it?
Put it before you do anything with the $_POST variables, so above the mail() function call.

Mac

Posted: Tue Jan 21, 2003 3:15 am
by jaimeg
I get the emails I just don't get the input from the fields from the senders.
name, email and message.

I get the headers that I typed.

My web site features sais it comes pre-configured with php, and since I get the emails but not the information, do I still need to check if I the sysadmin installed a mail server?

I would imagine if I did not have a mail server that I would not even get the emails. Am I wrong?

Like I said. I am brand new at this php stuff.
Any help is really appreciated.
Jaime

Posted: Tue Jan 21, 2003 3:22 am
by twigletmac
You've got a mail server because you get the e-mail so don't worry about that.

Oh, just spotted something try this:

Code: Select all

$msg = 'email sent from my web site'."\n"; 
$msg .= 'Sender''s Name: '.$_POST['sender_name']."\n"; 
$msg .= 'Sender''s email: '.$_POST['sender_email']."\n"; 
$msg .= 'Message: '.$_POST['mesage']."\n";
Mac

that did it.

Posted: Tue Jan 21, 2003 3:39 am
by jaimeg
WOW that did it.
The form works!!! .$
NOw I can go to sleep it's 2.41 am in ALbuquerque.

thank you so very much.

Part II tomorrow, I will have to figure out how to redirect to a confirmation page and error check the form.

Thank you .. Thank you.. Thank you.

Jaime

Posted: Tue Jan 21, 2003 4:39 am
by twigletmac
That's alright, it looks like your error reporting is either turned off, or turned down low, otherwise the code would have given you a bunch of errors, try putting this at the top of your scripts:

Code: Select all

ini_set('display_errors', TRUE);   //Print out errors (as a part of the output). 
error_reporting(E_ALL); //E_ALL  - All errors and warnings
Mac