Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 29th, 2003, 08:43 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default begining PHP, input box

Hello all,

I have a problem where I am trying to pass the data from a form called write.php to a thanks.php page and it will not display the content of the textbox onto the thanks page...

---- write.php--
<html>
<head>
<title>Writing to a file</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form method="post" action="thanks.php">
<input type="text" name="test1">
<input type="submit" value="Process">
</form>
</body>
</html>

---thanks.php----
<html>
<body>
Thank you for entering your name <?php echo $test1 ?> in our list..<br>
<a href="write.php">Clike here to go back to form</a>
</body>
</html>

i don't know why echo doesn't work, when I insert echo "test" it will display it on the page...

Thanks for all your help
Reply With Quote
  #2 (permalink)  
Old September 30th, 2003, 01:10 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Read this for starters:
  http://p2p.wrox.com/archive/beginnin...2002-11/17.asp

It it's not enough information, search for "register_globals" posts in p2p. There are hundreds.
  http://www.google.com/search?q=site:...ster%5Fglobals


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #3 (permalink)  
Old September 30th, 2003, 02:20 PM
Registered User
 
Join Date: Sep 2003
Location: Guildford, Surrey, United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try echoing $_POST['test1']

James S
Reply With Quote
  #4 (permalink)  
Old September 30th, 2003, 06:39 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks to both of you for the assistance.
I am still facing the same dilemma where I have used the $_POST variable to try and post the inputed characters... When I use the <form Method="GET"> it does show me the inputed fields in the url. I just cannot post it on the thank you page...

Thanks for the assistance, any further assistance would be greatly appreciated.
Reply With Quote
  #5 (permalink)  
Old September 30th, 2003, 07:12 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Uh, if the form method is "GET" then you need to access your form variables via the $_GET array, not $_POST.

This is all explained in detail in the FAQ link I posted, and in all the manual links at the bottom of that FAQ.


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #6 (permalink)  
Old September 30th, 2003, 07:14 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I should add that your original post uses the POST form method, not GET, so James' suggestion would've solved your original problem, though it doesn't do anything to teach you WHY it works; The more you learn and figure out for yourself, the more you can answer your own questions first.


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #7 (permalink)  
Old October 1st, 2003, 02:53 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Nik, and I did read the FAQ that you posted as well, and it was informative but still did not solve my problem. The only reason why I did a GET method and $_Get array was because I wanted to see if the data was being passed. Apparently it was being passed now why it wasn't being displayed on the next page when I used a POST is beyond me. Now all I am trying to do is figure out if that is a php configuration problem that Iam experiencing or if its just the CODE is incorrect...

again thanks for all the assistance....
Reply With Quote
  #8 (permalink)  
Old October 1st, 2003, 03:23 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wait, so it's still not working? If your code is correct (and I'll include a "correct" application below), and it's still not working, perhaps your web server is misconfigured and is preventing any user request variables (get, post, cookie) from reaching the PHP interpreter.

Here's that correct application:

<html>
<head><title>$_GET test</title></head>
<body>
<form method="get" action="<?php echo $_SERVER['PHP_SELF'];?>">
  <input type="text" name="input" />
  <input type="submit" name="submit" value="Go" />
</form>

<?php
if (isset($_GET['input'])) echo "You submitted: " . $_GET['input'];
else echo "\$_GET['input'] is not set.";
?>
</body>
</html>


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #9 (permalink)  
Old October 2nd, 2003, 07:15 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Nik,

It turned out to be my webserver, I reinstalled php again and presto it worked...

cheers...
Reply With Quote
  #10 (permalink)  
Old December 19th, 2003, 11:51 AM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello folks.

A small question. For the life of me, I couldn't find anything this specific through the search function.

I have the following code for data from a checkbox form:

<?php
echo "$choice1<br>";
echo "$choice2<br>";
echo "$choice3<br>";
?>


which I converted into this:

<?php
echo $_POST['choice1'];
echo $_POST['choice2'];
echo $_POST['choice3'];
?>

It works fine.

My question is where to put the <br>. It seemed logical to put it inside the single quote, but when I do that and hit submit, nothing comes out. For example, if I do this

<?php
echo $_POST['choice1<br>'];
echo $_POST['choice2'];
echo $_POST['choice3'];
?>

and I check off all three choices and hit submit, the first value doesn't come out on screen while the other two do.

I tried moving the <br> to various other places after "choice1" but I get parse errors.

Where do you put html in commands like $_POST?

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
INPUT BOX IN ASP/VBSCRIPT chinedu Classic ASP Basics 8 February 15th, 2007 02:47 PM
does not work register.php in ch 11 begining php5 tanvir_math BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 February 7th, 2007 05:03 PM
Input Box return value pakman Excel VBA 1 June 15th, 2005 04:29 AM
Input Box tucker Access VBA 2 May 21st, 2004 03:43 PM
Double search using an input text box Karel Access VBA 2 October 25th, 2003 10:29 PM



All times are GMT -4. The time now is 11:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.