hi, i have a problem:
firstly how do i get the address bar to say this
http://localhost/test.htm?user=
i would like this to be submitted via a form and then depending on what the username puts it will display
hi, i have a problem:
firstly how do i get the address bar to say this
http://localhost/test.htm?user=
i would like this to be submitted via a form and then depending on what the username puts it will display
Last edited by hmsnacker123; 04-15-2008 at 09:03 PM.
Well, what you could so is you have some javascript like this:
Then use a str.Code:var ext = document.url.split('?'); var exte = document.url.split('=');
Jeremy | jfein.net
if you wanna go easier than Javascript... php has got a easy line of code which is litterally one line to get the variable and its contents! Amazing right?
to do that... first do this:
IF your using php to get the information... you do this:Code:<form action="test.htm" method="GET"></form>
But lets say you have multiple inputs or you want to make a permanent link example belowPHP Code:<?php
$_GET['user'];//the name of the text input goes where 'user' is...
$_GET['pass'];
$_GET['otherstuff'];
?>make sure to put on index.php (or what ever the target page with the variables in the url) has the $_GET...Code:<a href="example.com/index.php?user=dank&othervariable=Iforgotmypassword&example=example">See dank's profile</a>
For extra variables add an & sign between the variable content and the next variable.
The variables cannot be over 100 characters long...
Its really easy and a really cool line of code in php... most user-content driven websites use url get methods to data...
THOUGH! I would not recommend transfering passwords using this...
Hopes this helps!
He can't use PHP, he needs javascript.
Here this should do it for you:
Code:<html> <head> <title>Please type your na...</title> </head> <body> <body onLoad="get_url()"> <script type="text/javascript"> function get_url(){ var find = "name="; var im_url = document.URL; var find_m = im_url.search(find); var full_u = im_url.substr(find_m+find.length); document.getElementById('welcome').innerHTML=full_u; } </script> <form action="" method="get"> <input type="text" name="name" /> <input type="submit" value="Enter!" /> </form> <div id="welcome"></div> </body> </html>
Last edited by Nile; 04-17-2008 at 12:53 PM.
Jeremy | jfein.net
The above script fills all the parameters to the pageVars variable just like PHP's $_GET variable.Code:var pageVars; function fillPageVars() { pageVars=undefined; pageVars=(document.location.search.length>1) ? document.location.search.substring(1).split('&') : new Array(0); for (var i=0; i<pageVars.length; i++) { tempArray=pageVars[i].split('='); pageVars[tempArray[0]]=decodeURIComponent(tempArray[1]); delete tempArray; } }
I cant use php because my apache does not support it please can you / anyone give a tutorial on how to set up php on apache. thanks![]()
LOL. Nile seems adamant about his code working for you. You might want to try it out and let him know how it goes
But if you still want to install PHP, here is a general tutorial. Installing PHP is probably the smarter way to go. You'll quickly run into limitations in this kind of application with Javascript (not to mention the potential accessibility issues).
Last edited by Medyman; 04-15-2008 at 06:32 PM.
Thanks, Nile Your JavaScript Worked.![]()
Bookmarks