Forum Moderators: coopster

Message Too Old, No Replies

Using Form Select and POST

want to eliminate query string in url

         

pjgarrit

5:46 pm on Jun 25, 2005 (gmt 0)

10+ Year Member



I have been using a form with "GET" method to select a date for a report stored in a MySQL table. It gives a URL "/view.html?report=253" and I'd prefer to use the report date which is unique and have the url be "/2005-06-25/".

My form and query:

$query = "SELECT id, DATE_FORMAT(date, '%M %d, %Y') AS d FROM reports WHERE YEAR(date) = '2005' ORDER BY id DESC";
$result = mysql_query ($query);

echo "<form method=\"GET\" action=\"./view.html\">
<span class=\"a2\"><b>2005:</b></span>
<select name=\"report\" class=\"select\">";

while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
echo "<option value=\"$row[id]\">$row[d]</option>";
}
echo '</select>
<input type="submit" value="GO">
</form>';

This query limits the selections from the table to 2005. I have separate form for 2004.

I have tried changing the method to POST but can't get the date to pass on where I'd like to set up a rewrite rule to write the url as "/$d/" or "/2005-06-25/".

I can rewrite the url fine with a text link just not with the form and to keep the page as compact as possible have had to live with the GET method and the url with a query string.

Thanks for any suggestions someone might have.

Burner

6:28 pm on Jun 25, 2005 (gmt 0)

10+ Year Member



I hope I'm understanding you right, you're just asking about how the url displays? If this is the case are you using Apache as a webserver? I could help out with a mod_rewrite rule if that's the case.

Burner

pjgarrit

7:38 pm on Jun 25, 2005 (gmt 0)

10+ Year Member



Yes - site is on an Apache server.

To clarify - I want to send the date of the report to the "view.html" page using POST as the form method so I can rewrite the url using a RewriteRule like:

RewriteRule ^([^.]+)$ view.php?d=$1 [L]

where "d" is the date of the report that is selected by the sql query.

I currently use GET method and it sends the id or date to the view.php page but the url displays with the query string.

Am just having trouble getting the POST method to pass the date variable.