Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 14th, 2006, 04:51 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying user input

Hi to all :)

the following code is supposed to call the php page and display what the user has input in the html page, the problem is: the php page is called successfully but it is NOT displaying anything except 'Your favorite author is:' !!! can anyone please spot the problem?? I'm using php 4.4.2, internet explorer, IIS, this is a copy-paste of the code, u may try it and c 4 urself

************
text.html
************

<html>
<head>
</head>
<body>
<form method="get" action="text.php">
Who is your favorite author?
<input name="him" type="text">
<br>
<br>
<input type="submit">
</form>
</body>
</html>

************
text.php
************

<html>
<head>
</head>
<body>
Your favorite author is:
<?php
echo $him;
?>
</body>
</html>

 
Old June 14th, 2006, 08:07 AM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to guillermo
Default

change the method of your form to post, then try <?php echo $_POST['him']?>

 
Old June 14th, 2006, 08:25 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

that is awesome :) it really worked !! thnx alot guillermo !! problem solved.
Quote:
quote:Originally posted by guillermo
 change the method of your form to post, then try <?php echo $_POST['him']?>

 
Old June 15th, 2006, 09:30 PM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to guillermo
Default

No problem. Your forms should always use the "post" method, and their values will always be $_POST['fieldname']. $_GET is generally used to get values out of the url, so in this case: http://domain.com/index.php?id=222&name=333

the following would be true:
$_GET['id'] = 222
$_GET['name'] = 333






Similar Threads
Thread Thread Starter Forum Replies Last Post
Encoding User Input tectrix BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 February 6th, 2008 06:58 AM
storing user input brainchild Javascript 2 March 1st, 2007 04:55 AM
validating user input hosefo81 Javascript How-To 12 March 3rd, 2004 09:32 AM
checking user input hosefo81 Javascript How-To 0 February 16th, 2004 11:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.