query strings

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

Post Reply
paul_r
Forum Newbie
Posts: 9
Joined: Fri Jun 13, 2003 11:21 pm

query strings

Post by paul_r »

hello! i have a problem passing data from one page to another. I made two sample pages:

//getname.html
<html>
<body>
<form action="handler.php" method="get">
first name: <input type="text" name="FirstName">
<input type="submit" value="submit">
</form>
</body>
</html>

//handler.php
<html>
<body>
<?php
print "hello $FirstName";
?>
</body>
</html>

after pressing the submit button on the first page, i get redirected to the second. in the second page, instead of dipslaying hello paul, i get an error saying that the variable $FirstName is unknown. I'm using microsoft IIS. I already installed php to it. It also has asp.net. Asp.net works fine. do you think my problem is because of having these two on one server? Or do I just have to configure something in my server? thanks!
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

You were almost there. Put

Code: Select all

<?php
$FirstName = $_GET['FirstName'];
?>
Above <html> in your handler.php file. You must get the submitted info before you can use it.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

and read Sticky: Before Post Read: Concerning Passing Variables in PHP 4.2+
it's not a sticky thread for nothing ;)
paul_r
Forum Newbie
Posts: 9
Joined: Fri Jun 13, 2003 11:21 pm

Post by paul_r »

ok. sorry about that. thanks anyway!
Post Reply