Jump to content

[SOLVED] $_GET variables from form and mod_rewrite - transform into directory structure?


vynsane

Recommended Posts

hi, all... i'm wondering if there's a way to send $_GET variables to a page in the same form as the mod_rewrite rules that i'm using. for example, this page:

 

http://invincible.comics-database.com/database/comicsByReleaseDate/01-2006

 

is really this:

 

http://invincible.comics-database.com/database/comicsByReleaseDate.php?month=01&year=2006

 

the form is on this page (under "search by release date"):

 

http://invincible.comics-database.com/database/

 

the form sends one select as the month and one select as the year. basically the question is: how can i take $_GET variables coming from that form ("month=01" and "year=2006") and turn it into the mod-rewrite emulated folder structure ("/01-2006")?

 

is there a mod_rewrite that can be done, or would i have to pass it through another script that transforms the $_GETs into the form i need and then redirect it to the proper version of the URL?

 

 

Link to comment
Share on other sites

is there a mod_rewrite that can be done, or would i have to pass it through another script that transforms the $_GETs into the form i need and then redirect it to the proper version of the URL?

 

just FYI, i solved my own problem at the end of my post - that's what i did - i turned the forms into POST instead of GET and created a passthrough script that redirects to the correct URL. it's actually a cool little technique and i made it a multi-purpose page so at the moment 5 different forms are using the passthrough.

Link to comment
Share on other sites

  • 3 weeks later...

Quick and Dirrty:

redirect.php:

<?php
$year = $_GET['year'];
$month = $_GET['month'];
$url = "http://invincible.comics-database.com/database/comicsByReleaseDate/".$month."-".$year;
header('Location:'.$url);
?>

 

Use this as the whole page. You should expand on it to do some input checking on your $_GET variables, but this should basically be it.

Remember, no spaces or HTML before this code or you'll get the dreaded "Headers already sent" Error.

 

Link to comment
Share on other sites

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.