Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

URL Query String

Options
  • 11-03-2013 2:23pm
    #1
    Registered Users Posts: 1,606 ✭✭✭


    Hi

    Just wondering is it possible to change a HTML select option via the URL Query String?

    On the site http://webmail4.register365.com, I can pass in a parameter as follows to populate the username.

    I am also looking to know can I change the version field using the same method. The field name is _version and the code behind it is. Using _version=4.4.3 does not seem to work.

    [HTML]<select id="webmail_version" name="_version">
    <option value="3.9">WebMail 3.9</option>
    <option selected="selected" value="4.4.3">4.4.3</option>
    </select>[/HTML]


Comments

  • Closed Accounts Posts: 249 ✭✭OneIdea


    sgarvan wrote: »
    Hi

    Just wondering is it possible to change a HTML select option via the URL Query String?

    On the site http://webmail4.register365.com, I can pass in a parameter as follows to populate the username.



    I am also looking to know can I change the version field using the same method. The field name is _version and the code behind it is. Using _version=4.4.3 does not seem to work.

    [HTML]<select id="webmail_version" name="_version">
    <option value="3.9">WebMail 3.9</option>
    <option selected="selected" value="4.4.3">4.4.3</option>
    </select>[/HTML]

    I'm not 100% sure I understand the question...

    I think your saying, if I send the version number in a string how can I post it to my form?
    <?php 
    
    $version = $_GET['version'];
    if(empty($version)){ 
    $version = "some default value";
    }
    
    ?>
    
    <select id="webmail_version" name="<?=$version;?>">
    
    </select>
    


  • Registered Users Posts: 185 ✭✭gaelicyoda


    sgarvan wrote: »
    Just wondering is it possible to change a HTML select option via the URL Query String?

    On the site http://webmail4.register365.com, I can pass in a parameter as follows to populate the username.


    The answer is yes, but what I think you're really asking is if the HTML specification provides a way to do this out of the box. The answer to that is no.

    You can add the parameter to the URL, but your page has to have some code in it to read that value and populate the select based on that. This is very easy using JSPs for example. I'd imagine quite easy using JavaScript as well.

    sgarvan wrote: »
    I am also looking to know can I change the version field using the same method. The field name is _version and the code behind it is. Using _version=4.4.3 does not seem to work.

    [HTML]<select id="webmail_version" name="_version">
    <option value="3.9">WebMail 3.9</option>
    <option selected="selected" value="4.4.3">4.4.3</option>
    </select>[/HTML]

    As mentioned above, HTML does not provide any mechanism to match the "_version" parameter in your URL:
    "http://....?[B]_version=4.4.3[/B]"
    
    to the select widget on the HTML page named "_version".

    Unfortunately, you have to write that logic yourself.
    Google it though, there's bound to be an endless number of examples of how this is done out there.


  • Registered Users Posts: 1,606 ✭✭✭sgarvan


    Cheers for the replies. Looks like I can't do this using HTML.

    The site http://webmail4.register365.com/ is not my site so I cannot add specific code to change the HTML select. I am trying to set the options on the page for certain users so that I can force them to use a certain version of this webmail all the time.


  • Registered Users Posts: 185 ✭✭gaelicyoda


    sgarvan wrote: »
    Cheers for the replies. Looks like I can't do this using HTML.

    The site http://webmail4.register365.com/ is not my site so I cannot add specific code to change the HTML select. I am trying to set the options on the page for certain users so that I can force them to use a certain version of this webmail all the time.


    Hmmm... try investigating the use of frames.

    You might be able to load the thirdparty page into a frame within your page and then set the select once it's loaded.


  • Moderators, Society & Culture Moderators Posts: 17,642 Mod ✭✭✭✭Graham


    Rather than trying to insert the values into the login page can you not check where the login form submits those values (the processing page)?

    You may then be able to submit values directly to the processing page (as long as that page isn't restricted to only accept input from its own page/domain).


  • Advertisement
  • Moderators, Society & Culture Moderators Posts: 17,642 Mod ✭✭✭✭Graham


    Try something like this (warning not tested) on your own web page:

    [HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    </head>
    <body>
    <form name="form" action="http://webmail4.register365.com&quot; method="post">
    <input type="hidden" name="_token" value="2741c70ff6e6078fb934d41c8bcc6c86" />
    <input type="hidden" name="_task" value="login" /><input type="hidden" name="_action" value="login" />
    <input type="hidden" name="_timezone" id="rcmlogintz" value="_default_" />
    <input type="hidden" name="_dstactive" id="rcmlogindst" value="_default_" />
    <input type="hidden" name="_url" id="rcmloginurl" value="" />
    <input name="_user" id="rcmloginuser" type="text" value="bob@bob.com"/>
    <input name="_pass" id="rcmloginpwd" type="password" value="secret123"/>
    <select id="webmail_version" name="_version">
    <option value="3.9">WebMail 3.9</option>
    <option value="4.4.3" selected="selected">4.4.3</option>
    </select>
    <input type="submit" class="button mainaction" style="cursor: pointer;" value="Login" />
    </form>
    </body>
    </html>[/HTML]


  • Closed Accounts Posts: 22,479 ✭✭✭✭philologos


    It's a post request not a get you'll have to submit the string in the body of the request not in the query string.

    Unless you make a post request using the parameters in the form there's not really a way of injecting this into the page.

    How are you doing this, with a programming language or manually as that would really really help.


  • Registered Users Posts: 1,606 ✭✭✭sgarvan


    At the moment I am just redirecting the users to http://webmail4.register365.com/?_user=blah@blah.com and then they type in the password. But they have to choose the version.

    I migrated servers and imported the address books into version 4.4.3 and keep getting asked where the addresses are because the users are logging into version 3.9.


  • Registered Users Posts: 1,606 ✭✭✭sgarvan


    Graham wrote: »
    Try something like this (warning not tested) on your own web page:


    Thanks for this. I had tried something along these lines already. Each time I submitted the request to login, it failed, Saying Invalid Request, data not sent.

    I believe that this is because of a generated token each time on logon.

    [HTML]<input type="hidden" name="_token" value="ba06436a56da599d7618c546afc45e9c" />[/HTML]


  • Closed Accounts Posts: 799 ✭✭✭Logical_Bear


    whoops sorry!


  • Advertisement
  • Moderators, Society & Culture Moderators Posts: 17,642 Mod ✭✭✭✭Graham


    Are you redirecting the users from your own web page? If you are you could probably grab the token before displaying the login form.


  • Registered Users Posts: 1,606 ✭✭✭sgarvan


    At the moment it is just a redirect ie www.domain.com/email goes to the webmail page with a certain email auto populated

    I will look into setting up a page and seeing if I can get the token. Cheers


Advertisement