Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: http://localhost/test.htm?user=

  1. #1
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default http://localhost/test.htm?user=

    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Well, what you could so is you have some javascript like this:
    Code:
    var ext = document.url.split('?');
    var exte = document.url.split('=');
    Then use a str.
    Jeremy | jfein.net

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    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:
    Code:
    <form action="test.htm" method="GET"></form>
    IF your using php to get the information... you do this:
    PHP Code:
    <?php 
    $_GET
    ['user'];//the name of the text input goes where 'user' is...
    $_GET['pass'];
    $_GET['otherstuff'];
    ?>
    But lets say you have multiple inputs or you want to make a permanent link example below
    Code:
    <a href="example.com/index.php?user=dank&othervariable=Iforgotmypassword&example=example">See dank's profile</a>
    make sure to put on index.php (or what ever the target page with the variables in the url) has the $_GET...
    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!

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    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

  5. #5
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    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;
    		}
    	}
    The above script fills all the parameters to the pageVars variable just like PHP's $_GET variable.

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    @BYK Yours doesn't answer his question.
    Jeremy | jfein.net

  7. #7
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    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

  8. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Your getting off topic, try the codes and see whats best for you .
    Jeremy | jfein.net

  9. #9
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by Nile View Post
    Your getting off topic, try the codes and see whats best for you .
    Quote Originally Posted by hmsnacker123 View Post
    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.

  10. #10
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    Thanks, Nile Your JavaScript Worked.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •