Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html form data in php page not being read in php action page?

Status
Not open for further replies.

KevinCO

Programmer
Oct 2, 2001
45
0
0
US
I have a php page that has a form with text boxes and such, with the form action going to another php page, but it is not transfersing the data when I try to access and echo it(either the shortened way or with the HTTP_GET_VARS or HTTP_POST_VARS methods). It works when the form and the text boxes are in a regular html page that has the same action and method as the php page with the form and text boxes. Anyone know why this is? I can't have form data in a php file? I have to use an html page?
 
I don't understand your question.

PHP outputs HTML with a form that includes form fields. The user inserts values into HTML form fields and submits the form. The values in the form are made available to whatever script the form is submitted to.

I'm not sure what you're trying to do.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
thanks for the reply, I'll give a simple example

lets say I have a file named One.html that has

<html>
<body>
<form action=&quot;Two.php&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;demotext&quot;>
<input type = &quot;submit&quot;>
</form>
</body>
</html>

Now I can access &quot;demotext&quot; using $demotext or as HTTP_POST_VARS[&quot;demotext&quot;] in the Two.php file, but, lets say that I rename One.html to One.php and not change anything else in the code. When I fill out the text box and hit submit, it does not transfer the data.
 
I took your example (changing &quot;Two.php&quot; in the form's action action attribute to &quot;two.php&quot;) and saved it as an HTML file. I created two.php consisting of:

Code:
<?php
print '<pre>';
print_r ($_POST);
?>

I pointed by browser to one.html, filled in the form, submitted the form, and got what I expected as the return from two.php.

I renamed one.html to one.php and pointed my browser to the new URL. I filled in the form, submitted, and got the same return as before.

What is your PHP run environment? What version of PHP are you running?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thanks for helping again

I'm using the free lycos thing, its PHP4u Version 3.0
Based on PHP-4.3.2

Here is the code for one.php:
<html>
<body>
<form action=&quot;two.php&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;demotext&quot;>
<input type = &quot;submit&quot;>
</form>
</html>

Here is the code for two.php:
<html>
<body>
<?
echo $demotext;
?>
</body>
</html>
 
Both pages work fine in Mozilla 1.4 on Windows XP.
It does not work wit IE 6.0 however.

You have the action attribute in the page just post to 'two.php'. I'd try to put in a full URL for testing. It is entirely possible that there is some internal redirection going on that loses the POSTed vars.

BTW, appending the demotext as a GET parameter (querystring) works.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top