Jump to content

PHP include pass variables to $_POST items


vin301

Recommended Posts

I want to do the following:

The main page will pull in another file that has a table to display the form results.

MAIN PAGE
$str = file_get_contents("formFile.php");

AND formFile.php has the following

Name: <?= $_POST['fullname'] ?>
Address: <?= $_POST['address'] ?>


When I do this the POST values do not get filled in. What do I need to do? If I do an include() it will work but I cannot assign the include to the var ... this won't work $str = include();

Thoughts?
[!--quoteo(post=387518:date=Jun 24 2006, 01:44 PM:name=vin301)--][div class=\'quotetop\']QUOTE(vin301 @ Jun 24 2006, 01:44 PM) [snapback]387518[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I want to do the following:

The main page will pull in another file that has a table to display the form results.

MAIN PAGE
$str = file_get_contents("formFile.php");

AND formFile.php has the following

Name: <?= $_POST['fullname'] ?>
Address: <?= $_POST['address'] ?>
When I do this the POST values do not get filled in. What do I need to do? If I do an include() it will work but I cannot assign the include to the var ... this won't work $str = include();

Thoughts?
[/quote]

file_get_contents get the contents of a file and puts it into a string.

in order to get some values for fullname and address you need to display formfile.php then when the user clicks the submit button, fullname and address will have some values that you can use.

how you direct the user to your form can be done a few different ways so you will need to post some more code in order for anyone to track down the problem

include() will just include the file into your script. it can be just some html or some code to be executed.

include('formfile.php');

post some more code...
the form that sends the posted vars has to be actually executed, and post it to the target script. then you can oh idk, make them into session vars and pass it to your new script. but you can't simply include a file and expect those vars to be there by default. other things have to be executed in order for the post vars to be generated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.