Hi guys i have a small problem hope someone can help me on this.... I have this form Ex: <form action="newpage.php" method="get" > <input type="text" name="yourtext" value="yourtextetc" /> <input type="text" name="urlname" value="inputurlname" /> <input type="submit" value="create" /> Then after user submits the form i get this in url ... http://mysite/newpage.php?yourtext=y...e=inputurlname Here is the problem: How can i convert http://mysite/newpage.php?yourtext=y...e=inputurlname In to http://mysite/inputurlname and in html i can see yourtextetc using php or javascript.... First one to help with this problem will win 3$ paypal...
You'd have to use a .htaccess to do that. and your form would either need to use POST with a php header redirect or a javascript to accomplish your task
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html Just google up mod_rewrite and plenty of resources should appear.
It will not work like that i tried something like that... because user adds those value and i don't think it is possible for user to edit htaccess values..... example <input type="text" name="yourtext" value="hi my name is Jimmy...user inputed this" /> <input type="text" name="urlname" value="Jimmy" /> So in browser Jimmy has to see this: In url address bar http://mysite/Jimmy and in html hi my name is Jimmy...user inputed this without using mysql ....
You can simply use jquery and show the user just the result of operation. Check documentation here http://api.jquery.com/jQuery.post/
RewriteCond %{REQUEST_URI} newpage.php$ RewriteCond %{QUERY_STRING} ^urlname=([A-Za-z0-9\+]+)$ RewriteRule ^(.*)$ /%1? [R=301,L] RewriteRule ^([^+]+)\+([^.]+)$ /$1-$2 [R=301,L] RewriteRule ^(.*)$ newpage.php?urlname=$1&a=1 [L] Code (markup): try this on htaccess . no php coding needed. if its not working, you need a little modification
The rewrite cond works but it won't automatically generate the url, you'd not some basic javascript form processing for that. Bind the submit to a window.location command instead.
A bit ugly way, but might do: newpage.php: session_start(); $_SESSION['yourtext']=$_GET['yourtext']; $_SESSION['inputurlname']=$_GET['inputurlname']; header("Location: http://mysite/$_SESSION['inputurlname']"); Code (markup): .htaccess: I guess any from previous posts :) Code (markup): To get access to yourtext variable: echo $_SESSION['yourtext']; Code (markup):
nope nothing happens same thing using your code now.... http://1o.ro Can you add a .htaccess also, to try your version of .htaccess....?
How about this for newpage.php <?php $yourtext = $_GET["yourtext"]; $urlname = $_GET["urlname"]; mkdir($urlname); $f = fopen($urlname."/index.html", "w"); fwrite($f,"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n"); fwrite($f,"<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); fwrite($f,"<head profile='http://gmpg.org/xfn/11'>\n"); fwrite($f,"<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n"); fwrite($f,"<title></title>\n"); fwrite($f,"</head>\n"); fwrite($f,"<body>\n"); fwrite($f,"<h1>".$yourtext."</h1>\n"); fwrite($f,"</body>\n"); fwrite($f,"</html>"); fclose($f); header( "Location: ".$urlname) ; ?> Code (markup): I have no idea if that is safe or not, so caveat emptor mate!