vin301 Posted June 24, 2006 Share Posted June 24, 2006 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 followingName: <?= $_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 Link to comment https://forums.phpfreaks.com/topic/12815-php-include-pass-variables-to-_post-items/ Share on other sites More sharing options...
vin301 Posted June 24, 2006 Author Share Posted June 24, 2006 nevermind. I fixed it Quote Link to comment https://forums.phpfreaks.com/topic/12815-php-include-pass-variables-to-_post-items/#findComment-49135 Share on other sites More sharing options...
AndyB Posted June 24, 2006 Share Posted June 24, 2006 Thoughts? Completely baffled.I can't understand what you're trying to do. I can't understand why you're trying to do it. "If I do an include it will work ..." - so why not just use include()? Where do these $_POST variables originate. Quote Link to comment https://forums.phpfreaks.com/topic/12815-php-include-pass-variables-to-_post-items/#findComment-49137 Share on other sites More sharing options...
Drumminxx Posted June 24, 2006 Share Posted June 24, 2006 [!--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 followingName: <?= $_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 probleminclude() 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... Quote Link to comment https://forums.phpfreaks.com/topic/12815-php-include-pass-variables-to-_post-items/#findComment-49138 Share on other sites More sharing options...
.josh Posted June 24, 2006 Share Posted June 24, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/12815-php-include-pass-variables-to-_post-items/#findComment-49139 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.