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?

 

 

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.

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

 

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.