How to retrieve hidden form variables

  • Rob

    Rob - 2007-02-21


    I have a page produces dynamic hidden variables for a form post.

    I need to be able to submit those same variables to the form. How can I use Snoopy to do this?


    1. Log into site

    $submit_vars['user'] = 'user';
    $submit_vars['pwd'] = 'pwd';
    $submit_vars['submit'] = 'submit';

    $submit_url = "";
    if (!$snoopy->submit($submit_url,$submit_vars)) {
        die ("error fetching document: ".$snoopy->error."\n");

    2. Go to form page (with dynamic hidden variables)

    $url = '';

    if (!$snoopy->fetch($url)) {
        die ("error fetching document: ".$snoopy->error."\n");

    3. Submit to form (but with dynamic hidden variables)

    $submit_vars['??'] = '??'; //can I set the hidden form variable here somehow?

    $submit_url = '';
    if (!$snoopy->submit($submit_url,$submit_vars)) {
        die("error fetching document: ".$snoopy->error."\n");       


    • sharp

      sharp - 2007-02-21

      The only 2 things that snoopy can give you are:
      1) HTTP Headers


      POST /mcmd/events HTTP/1.1
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20061204 Firefox/
      Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
      Accept-Language: en-us,en;q=0.5
      Accept-Encoding: gzip,deflate
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 300
      Connection: keep-alive
      Content-Type: application/x-www-form-urlencoded
      Content-Length: 87
      Pragma: no-cache
      Cache-Control: no-cache

      2) Page content
      well, you know ... the content of the page you`ve requested (either by post(aka: submit) or get(aka: fetch))
      In other words, no.. you cannot see the hidden fields of a form by using something like: $snoopy->form["formName"]->field["fieldName"];
      But, you can do a fetch on the form you wish to submit ... manually parse the content for any hidden fields (gather from this parsing whatever you wish) and then setup your snoopy and submit! :) ... hope this helps! cheers ;)

      btw, I have a friend which goes by the name of spaceboy... any chance you`re from Romania? :)

    • Rob

      Rob - 2007-02-21

      Thanks for the help. I'm thinking I'll have to go with option #2, and parse the form contents.

      Thanks again,

      p.s. Sorry, not the same person, as I'm from Canada :)


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks