 |
| 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
|
|
|
|

September 29th, 2003, 08:43 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

September 30th, 2003, 02:20 PM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
try echoing $_POST['test1']
James S
|
|

September 30th, 2003, 06:39 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

September 30th, 2003, 07:12 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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/
|
|

September 30th, 2003, 07:14 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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/
|
|

October 1st, 2003, 02:53 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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....
|
|

October 1st, 2003, 03:23 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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/
|
|

October 2nd, 2003, 07:15 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks Nik,
It turned out to be my webserver, I reinstalled php again and presto it worked...
cheers...
|
|

December 19th, 2003, 11:51 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|
|
 |