Jump to content


Photo

PHP include pass variables to $_POST items


  • Please log in to reply
4 replies to this topic

#1 vin301

vin301
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 June 2006 - 05:44 PM

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?

#2 vin301

vin301
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 June 2006 - 05:54 PM

nevermind. I fixed it

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 June 2006 - 05:57 PM

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.
Legend has it that reading the manual never killed anyone.
My site

#4 Drumminxx

Drumminxx
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts
  • LocationUSA

Posted 24 June 2006 - 05:57 PM

[!--quoteo(post=387518:date=Jun 24 2006, 01:44 PM:name=vin301)--][div class=\'quotetop\']QUOTE(vin301 @ Jun 24 2006, 01:44 PM) View Post[/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...

:: gucci.com ::
:: blockbuster.com ::

--------------------

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 24 June 2006 - 06:02 PM

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users