View Full Version : Create a dynamic url

08-13-2007, 12:56 PM
I want to create a dynamic URL by using mod_rewrite, to let user post their thread like this forum does.

And i want to rewrite my all request as following:
domain.com/form and Mod_Rewrite -> domain.com/index.php?topic=form and Mod_Rewrite

In the .htaccess file, i wrote the rewite rule as following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)?$ index.php?name1=$1 [L]

But the problem for me is after a user type his topic for his new thread, how i get the value of the topic and put it into
action, let the action="value of the topic". For example, if the value of the topic is "how to use mod_rewrite", then
i want the action="how to use mod_rewrite".

Could anybody give me some idea how to do that by php. Thanks

<form name="input" action="????????" method="get">
<input type="text" name="topic" value="type your topic here" size="20">
<textarea rows="10" cols="30"> Type your massage here </textarea>
<input type="submit" value="Submit">


08-13-2007, 04:49 PM
You can dynamically assign your form attributes using Javascript...

<form name="input" method="get">
<input type="submit" name="formSubmit" value="post message" onsubmit="document.input.action = document.formSubmit.value;">

(not tested)

08-14-2007, 09:53 AM
Thanks a lot.