Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.