i picked up a book on php and this what it told me to do
this code is from test.html
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="handleform.php" method="post">
first name
<input type=text name="firstname" size=20><br>
last name <input type=text name="lastname" size=40> <br>
e-mail adress <input type=text name="email" size =60> <br>
comments <textarea name="comments" rows=5 cols=40></textarea><br>
<input type=submit name="submit" value="submit!"></form>
</body>
</html>
this code is from handleform.php
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
print "your first name is $firstname .<br>\n";
print "your last name is $lastname .<br>\n";
print "your email name is $email .<br>\n";
print "this is what u had to say: <br>\n $comments <br>\n";
?>
</body>
</html>
when i run the code i get these error messages
Quote:
Notice: Undefined variable: firstname in C:\Documents and Settings\can opener\Desktop\cantheham\handleform.php on line 10
your first name is .
Notice: Undefined variable: lastname in C:\Documents and Settings\can opener\Desktop\cantheham\handleform.php on line 11
your last name is .
Notice: Undefined variable: email in C:\Documents and Settings\can opener\Desktop\cantheham\handleform.php on line 12
your email name is .
Notice: Undefined variable: comments in C:\Documents and Settings\can opener\Desktop\cantheham\handleform.php on line 13
this is what u had to say:
|
ok i have several questions.
First my book says that in PHP u dont need to decalar vars like you do in "c" its says that its declared as soon as it is used so how can it be undeclared?
Second why would my book say to use print instead of echo as ive seen everywhere else any advantages to either one or disavantages?
Third why would the error messages show the local directory if this script is run on a server? shouldnt it show teh vir dir path?
fourth why dosent my code work any thoughts?
thank you for your time
can