Jump to content

clean url and forms


MDanz

Recommended Posts

I've recently used mod_rewrite and changed my .htaccess allowing clean urls.  Is there a tutorial that tells me how to use $_GET with a clean url?

 

for instance how do i get the name with the clean url($_GET method)?

 

messy url

example.com/play.php?id=203&name=test

 

clean url

example.com/videos/play/203/test

 

 

also when using forms is it as simple as changing

<form action='submit.php' action='get'>

to

<form action='submit' action='get'>

or do i have to do something else?

 

 

Link to comment
https://forums.phpfreaks.com/topic/243461-clean-url-and-forms/
Share on other sites

Your clean URL should rewrite all the variables into the messy URL so you won't have to do anything with the $_GET. As for as the PHP script is concerened, it dosn't matter if it was a clean URL or messy.

 

Forms are a different matter though, the action needs to be the working clean URL (not just 'submit'). If you're using GET forms then it will always look ugly. If you have several fields to submit try using POST where you can have a clean URL as the action, and all of the post data will be hidden from the URL. Depends what sort of data you're submitting in the form.

Link to comment
https://forums.phpfreaks.com/topic/243461-clean-url-and-forms/#findComment-1250132
Share on other sites

Your clean URL should rewrite all the variables into the messy URL so you won't have to do anything with the $_GET. As for as the PHP script is concerened, it dosn't matter if it was a clean URL or messy.

 

Forms are a different matter though, the action needs to be the working clean URL (not just 'submit'). If you're using GET forms then it will always look ugly. If you have several fields to submit try using POST where you can have a clean URL as the action, and all of the post data will be hidden from the URL. Depends what sort of data you're submitting in the form.

 

Thanks for help.

 

So your saying example.php?name=test and example/name/test.. if i use $_GET['name']; on the clean url it will be "test"?..

 

and i should change my GET forms to POST(hidden data), for the sake of clean urls?

 

Link to comment
https://forums.phpfreaks.com/topic/243461-clean-url-and-forms/#findComment-1250137
Share on other sites

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.