views:

31

answers:

1

how to manage the use of both $_SERVER['PHP_SELF'] in action of form and htaccess for url-rewriting?

If I submit a form and in the action attribute of it i pass "$_SERVER['PHP_SELF']" and at the same time i am using url rewriting for the same page.. then these two things will contradict each other resulting in the display of action value of form in address bar.. so how can i manage this to get the url rewrited form of $_SERVER['PHP_SELF']?

here the rewrite rule is to change the name of url file likewise as if form is submitted to any file say direction.php then rewrite will change it to something 30/redirect.html

+1  A: 

I am not sure what rewrite setup you have got so my guess is you have to specify the url in form action. You'd not be able to use $_SERVER['PHP_SELF'] as it will return the path of file which is actually being executed.

For example:

<form action="'.$_SERVER['PHP_SELF'].'">
to
<form action="'./url/as/per/rewrite'].'">

If this doesn't serve the purpose. You can have a look at $_SERVER['REQUEST_URI'] or

$_SERVER['REDIRECT_QUERY_STRING']
$_SERVER['REDIRECT_URL'] 

and update the form action value.

I hope it helps.

Wbdvlpr