Helpful Information
 
 
Category: Programming Languages
PHP email example

Hi,
I'm new to PHP and I'm trying an example from a book. This example is a small application that takes the output from a form and generates an e-mail message containing the form's contents. This is called Ex5.html :

<html>
<head><title>Example #5</title></head>
<body>
<form method=POST action=example_5.php3>
EMail Address:<INPUT TYPE=TEXT NAME="email_address"><br>
Phone Number: <INPUT TYPE=TEXT NAME="phone_number<br>
<INPUT TYPE=SUBMIT NAME=SUBMIT>
</form>
</body>
</html>

-----------------------------------
and this is called example_5.php3 :
-----------------------------------

<?PHP

$message = sprintf("Form data -----------------n");

while(list($key, $val) = each($HTTP_POST_VARS)) {
$message .= sprintf(#34>[%s]: %sn", $key, $value);
}

$message .= "n";
$message .= "More Information ------------------n");
$message .= "The user's IP address is";
$message .= getenv("remote_addr").".n";
$message .= "The user is running the web browser ";
$message .= getenv("http_user_agent").".n";

mail("bijanbel@excite.com", "Feedback Form", $message, "
From: Feedback someone@hotmail.com" );

?>
to invoke this I go to the html file with
my browser I fill out the form and submit.
then I get the following error messages :

Warning: Variable passed to each() is not an array or object in
/home/httpd/html/tests/example_5.php3 on line 5
------------------------------------
Warning: Unexpected character in input: '' (ASCII=92) state=1 in
/home/httpd/html/tests/example_5.php3 on line 6
-------------------------------------
Parse error: parse error, expecting `')'' in /home/httpd/html/sheilabel/tests/example_5.php3 on line 7
------------

>>> Does anyone have any idea how to fix this ? Some how it is not recognizing $HTTP_POST_VARS as an array but why I don't know.
>>> Please help. Thanx

hi i'm a newbie, but
it looks like this is what's wrong on line 6$message .= "More Information ------------------n");

remove the ) before ;
and i think the problem is solved http://www.devshed.com/Talk/Forums/smile.gif

good luck,

Jan, the Netherlands.










privacy (GDPR)