1 Replies - 3177 Views - Last Post: 10 May 2008 - 09:30 PM Rate Topic: -----

#1 Eltrusko   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-May 08

I need help with passing variables from 1 page to another

Post icon  Posted 10 May 2008 - 02:26 AM

How to USE source code(browser generated output)with value of variable using "function highlight_file($file, TRUE);" of a php file so that i can convert it into a html file or text file and able to upload that html file to Server..


Actually file setup is like that......

"page1.php" passes variable with value to "page2.php" and page3.php contains

<?php
$contents = file_get_contents('http://localhost/test/page2.php');
$fp = fopen('tmp.txt','r+');
fwrite($fp,$contents);
fclose($fp);
highlight_file('tmp.txt');
?>



when i trigger an event(submit) on page2.php then only page3.php will be executed...
everything is goin on fine....except that value of the varibale........
somebody told me the problem not the solution .......


He told me:-" post variables are generated at run time when a form from a page move towards to next page that have $_POST[] variables so that it may have values but as u are not forwarding and using it directly how will they get the values ??"

So, what should i do & where i have to make changes? plz reply........

** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: I need help with passing variables from 1 page to another

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6642
  • View blog
  • Posts: 30,931
  • Joined: 10-May 07

Re: I need help with passing variables from 1 page to another

Posted 10 May 2008 - 09:30 PM

Here is a Tutorial on using $_GET & $_POST to pass & gather information from one page to another.

Quote

when i trigger an event(submit) on page2.php then only page3.php will be executed...
everything is goin on fine....except that value of the varibale........
somebody told me the problem not the solution .......

Could you elaborate? If I do understand this correctly, you are trying to use a variable that you set on page1.php, however it does not have a value on page2.php. You would need to pass it, either with $_GET or $_POST, or create a session, so that all session variables are available, & you would not have to pass them from page to page.

Here is a Tutorial on sessions in PHP, & here & here are two great Snippets that explain sessions usage in PHP.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1