简体   繁体   中英

after login handling webpages through php curl program

I'm not able to post values to field and process further steps to download a file. Could anyone suggest where I'm going wrong?

    extract($_POST);  
      $url=header("Location: http://gis.lntecc.com/bwssblnt/Scada.aspx?   field1=Kathriguppe%2cSW2DM0402%2c235505H073%2c450");
   $fields =array(
            "TextBoxFromDate" => urlencode("2014-10-01"),
            "TextBoxToDate" =>  urlencode("2014-10-09")  
           );

    foreach($fields as $key => $value) 

    $fields_string .= $key.'='.$value.'&';

    rtrim($fields, '&');

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec($ch);
    echo $result;
    curl_close($ch);

Where did I make a mistake since I'm not able to post values to the field?

Simply remove that huge space in your URL:

 $url=header("Location: http://gis.lntecc.com/bwssblnt/Scada.aspx?   field1=Kathriguppe%2cSW2DM0402%2c235505H073%2c450");

Becomes:

 $url=header("Location: http://gis.lntecc.com/bwssblnt/Scada.aspx?field1=Kathriguppe%2cSW2DM0402%2c235505H073%2c450");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM