p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Beginning PHP (http://p2p.wrox.com/forumdisplay.php?f=95)
-   -   begining PHP, input box (http://p2p.wrox.com/showthread.php?t=4429)

dungey September 29th, 2003 08:43 PM

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

nikolai September 30th, 2003 01:10 PM


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/

jscomputing September 30th, 2003 02:20 PM

try echoing $_POST['test1']

James S

dungey September 30th, 2003 06:39 PM

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.

nikolai September 30th, 2003 07:12 PM

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/

nikolai September 30th, 2003 07:14 PM

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/

dungey October 1st, 2003 02:53 PM

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

nikolai October 1st, 2003 03:23 PM

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/

dungey October 2nd, 2003 07:15 PM

thanks Nik,

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

cheers...

minguy December 19th, 2003 11:51 AM

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?



All times are GMT -4. The time now is 07:53 PM.

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