Jump to content

[SOLVED] Preserve POST query while Paging Records with GET


erichpowell

Recommended Posts

I am getting a bit confused here.  So I have a web page (php) with some form fields which are submitted using POST.  The values in these fields are used as parameters in a MySQL query and the resulting records are returned in a table below the form fields.  So far so good.

 

The confusion arose when I tried to add 'paging' capabilities to the web page.  The URLs for 'next' & 'previous' specify parameters regarding which page of records to show: http://127.0.0.1/newbiz/TMPmdms6a0qix.php?pageNum_Presidents=1&totalRows_Presidents=12 .  However, this url does not contain the parameters for the query and thus, my query gets lost - kind of an important detail when you're trying to get more records from the same query.

 

The question, then, is if I have to convert my form fields to GET so that they appear in the URL too.  Or whether there is some way to implement 'paging' with POST.  (Or whether POST & GET can be integrated). 

 

I should mention that I originally gravitated towards POST because I read that it was more secure and am a bit reluctant to change my form fields to GET.  Perhaps that is unwarranted. 

One thing I found out by accident was declaring my FORM like this:

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

 

Whatever link you navigate from is recreated inside the FORM declaration with all the $_GET parameters meaning reading using $_POST is possible to read the data from the submitted form and $_GET can also be used to read the URL. I was also having the same problem in that FORM data was missing from the URL.

 

 

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.