email form help
Moderator: General Moderators
email form help
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);
?>
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);
?>
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Which version of PHP is the server running? To find out just run this script:
What do you get if you put the following into the script that handles the information from the form:
Mac
Code: Select all
<?php
echo 'Current PHP version: ' . phpversion();
?>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>';- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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
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
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You've got a mail server because you get the e-mail so don't worry about that.
Oh, just spotted something try this:
Mac
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";that did it.
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
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
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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:
Mac
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