Jump to content

processing and displaying data


rpjd

Recommended Posts

I have page1.php which has a post form and page2.php which display data/results.  I have a seperate php script file which queries a database.  Having completed the query and assuming a result, I would end up with something like

while($result = mysql_fetch_assoc($query))

how do I get the data onto the display page.  Looking at example approaches I found this using a go-between file

<?PHP 
include_once(process.php;
process($_POST);
display_results; 
?>

would display_results be a form of redirect?  If not?

Any help appreciated.

Link to comment
https://forums.phpfreaks.com/topic/229360-processing-and-displaying-data/
Share on other sites

Your form is going to post to it's target, and that script will have the values from the form in the $_POST.  Assuming you need to use the post in your query, your results script should just contain or include the query.  There is no redirect or intermediary involved.

Just create a new .php file and put the connection information in there.

 

For added security, you can save it outside your document root (more info on that here if you're interested: http://www.tuxradar.com/practicalphp/17/1/3).

 

Then, when you need to run a query, just include that file before the query is run.

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.