PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Random
Forum Commoner
Posts: 30 Joined: Wed Mar 12, 2003 5:38 pm
Post
by Random » Wed Mar 12, 2003 5:38 pm
Okay, I just got a book..."SAMS Teach Yourself PHP in 24 Hours". I am on hour 9 "How to create and retrieve user data". It shows the following things:
Code: Select all
<HTML>
<HEAD>
<TITLE>Listing 9.2 a Simple HTML Form</TITLE>
</HEAD>
<BODY>
<form action="process.php">
<input type="text" name="user">
<br>
<textarea name="address" rows="5" cols="40">
</textarea>
</FORM>
</BODY>
</HTML>
and the process.php is this:
Code: Select all
<HTML>
<HEAD>
<TITLE>Listing 9.3 Reading input from the form in Listing 9.2</TITLE>
</HEAD>
<BODY>
<?php
print "Welcome <b>$user</b><P>\n\n";
print "Your address is:<P>\n\n<b>$address</b>";
?>
</BODY>
</HTML>
This was copied word for word from the book. When I enter my name and address in the boxes, it comes up on the process.php page like this:
Welcome
Your address is:
and leaves it blank. Please post how to fix and what the book is missing. Thanks
redJag
Forum Newbie
Posts: 18 Joined: Fri Jan 31, 2003 12:17 am
Post
by redJag » Wed Mar 12, 2003 5:48 pm
changing it to "welcome ".$POST_[user]; should work. although you might have to define the method on the HTML page. try that though.
Random
Forum Commoner
Posts: 30 Joined: Wed Mar 12, 2003 5:38 pm
Post
by Random » Wed Mar 12, 2003 5:49 pm
ok thanks I will try that and post how it goes...kinda odd that this well of a book, and how many it sells, forgot to include that... Maybe he will make a version 2.0 of his book
Random
Forum Commoner
Posts: 30 Joined: Wed Mar 12, 2003 5:38 pm
Post
by Random » Wed Mar 12, 2003 6:04 pm
did i write this right?
Code: Select all
<HTML>
<HEAD>
<TITLE>.: Processing Form :.</TITLE>
</HEAD>
<BODY>
<?PHP
print "Welcome <b>$_POSTї'user']</b><P>\n\n";
print "Your address is:<P>\n\n<b>$_POSTї'address']</b>";
?>
</BODY>
</HTML>
redJag
Forum Newbie
Posts: 18 Joined: Fri Jan 31, 2003 12:17 am
Post
by redJag » Wed Mar 12, 2003 6:12 pm
yes, for some reason i wrote it wrong, but you have it down correctly. if thats not working, set the method in the form to POST and it should work perfectly.
Random
Forum Commoner
Posts: 30 Joined: Wed Mar 12, 2003 5:38 pm
Post
by Random » Wed Mar 12, 2003 6:13 pm
ok nevermind...i reread your thing...
Code: Select all
<HTML>
<HEAD>
<TITLE>.: Processing Form :.</TITLE>
</HEAD>
<BODY>
<?PHP
print "Welcome <b>".$_POSTї'user']."</b><P>\n\n";
print "Your address is:<P>\n\n<b>".$_POSTї'address']."</b>";
?>
</BODY>
</HTML>
net7
Forum Commoner
Posts: 31 Joined: Wed Mar 12, 2003 1:27 pm
Post
by net7 » Thu Mar 13, 2003 12:37 am
Works both ways, and the book didn't have it wrong. See older versions of php had it so if there was a variable passed by a form or URL you could use the variable in a script with $variable. Now you have to use
$_POST['variable']
$_GET['variable']
$_REQUEST['variable']
depending on which method you defined in the form.