Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Design
php variables passing issue
Drexl Spivey
Hi all,
Anyone can tell me why I get an error message "Notice: Undefined variable: comments in C:\Inetpub\wwwroot\test\do.php on line 9"
Here is the code :
form.htm:
<html>
<body>
<form action="do.php" method="post">
username: <input type="text" name="username"><br>
address: <input type="text" name="useraddr"><br>
<textarea name="comments"></textarea>
<input type="submit" value="Do">
</form>
</body>
</html>
do.php:
<?php
#recipient's email address
$to = "me@yahoo.com";#here I enter my email
#Subj
$re ="Website Feedback";
#message from the form
$msg=$comments;
#send now
mail($to,$re,$msg);
?>
<html><body>
thanks!<br>
</body>
</html>
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
Cake Fiend
Global vars are most likely turned off. Use the superglobal $_POST array (google it if you don't know what it is).
Drexl Spivey
Bingo!
I replace $comments with $_POST["comments"]
Thanks!