Reputation: 23
i'm building a simple e-commerce app and i'd like to make my url's "clean". Ok, i've already done some stuff to get there but i'm getting confused now :/
My current situation:
www.example.com/products
On this page i've some products with their id, title and all other stuff displayed
When i click on the title of a product, i submit a form with the id & name and i'd like to goto
www.example.com/detail/name_of_product
<form name="prodDetail" action="detail" method="post">
In detail.php i get the product id by $_POST because it comes in by submitting the form. then i can do all my stuff as needed to display the product details.
So far so good.
but if i do <form name="prodDetail" action="detail/'.$prodName.'"method="post">
i got nothing but a blanc page :/ Notice the '/' if i replace it with a '?' then it works but i got an ugly url with an ? in it:/
So i think my htaccess file doesn't alow me doing that :/
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?action=$1&1id=$2&2id=3$ [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?action=$1&2id=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ index.php?action=$1 [L,QSA]
i'm alo using a 'switcher.php' this file catches the 'action' and swith me to the right page using a function. i call this script in my index.php.
$action = isset($_GET['action']) ? $_GET['action'] : "default";
switch ($action){
case 'product';
showproduct();
break;
default:
defaultpage() //home.php is default
}
So if i submit a form to 'detail' the switcher points me to detail.php.
Sry for my bad english
Hopefully someone can help me :)
Upvotes: 0
Views: 119