You seem confused with POST & GET, instead of using _POST to retrieve
values from the form, you use $senders_name, and further down you set
$_POST["msg"], which will only be used in the same php code on the same
page

Try


$msg = "Sender's Full Name:\t" . $_POST['sender_name'] . "\n";
$msg .="Sender's E-mail:\t" . $_POST['sender_email'] . "\n";
$msg .="Did you like the site?\t" . $_POST['like_site'] . "\n";
$msg .="Additional Message:\t" . $_POST['message'] . "\n\n";

$mailheaders = "From: yoyo.monash.edu.my\~nthonyak\M\n";
$mailheaders .="Reply-To: " . $_POST['sender_email'] . "\n\n";

mail("[EMAIL PROTECTED]", "Feedback Form", $msg, $mailheaders);

--
Chris Kay (CK)
Eleet Internet Services
M: 0415 451 372
P: 02 4620 5076
F: 02 4620 7008
E: [EMAIL PROTECTED]

-----Original Message-----
From: merryE [mailto:[EMAIL PROTECTED] 
Sent: Friday, 29 August 2003 2:38 AM
To: [EMAIL PROTECTED]
Subject: [PHP] undefined variable

Can anyone tell me what's wrong with my code? I tried to create a form
in html and redirect it to php. but result said:  
Notice: Undefined variable: sender_name in c:\program files\apache
group\apache\htdocs\do_feedback.php on line 2 and for all the variables
("sender_email", "like_site", and "text area").
I have been tring to use variable but it is always said "Undefined
variable".
Please help, Thanks.

This is the code for form

<FORM method="POST" action="do_feedback.php">
<p>your name: <INPUT type="text" NAME="sender_name" size=30></p>
<p>your email: <INPUT type="text" NAME="sender_email" size=30></p>
<p> Did you like the site?
<INPUT type="radio" NAME="like_site" value="Yes" checked> yes
<INPUT type="radio" NAME="like_site" value="No"> no
</p>
<p>Additional message:<br>
<textarea name="message" cols=30 rows=5></textarea>
</p>
<INPUT type="submit" value="Send">
</FORM>

Code for php:
<?
$_POST["msg"] = "Sender's Full Name:\t$sender_name\n";
$_POST["msg"] .="Sender's E-mail:\t$sender_email\n";
$_POST["msg"] .="Did you like the site?\t$like_site\n";
$_POST["msg"] .="Additional Message:\t$message\n\n";

$_POST["mailheaders"] = "From: yoyo.monash.edu.my\~nthonyak\M\n";
$_POST["mailheaders"] .="Reply-To: $sender_email\n\n";

mail("[EMAIL PROTECTED]", "Feedback Form", $msg, $mailheaders);

echo $_POST["sender_name"];
echo "<P align=center>We appreciate your feedback</P>";
 ?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to