Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3277672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:23:43+00:00 2026-05-17T19:23:43+00:00

I’ve been working on writing a script which automatically logs me into my school’s

  • 0

I’ve been working on writing a script which automatically logs me into my school’s network, checks if the classes I’m trying to get into are no longer completely full, and if a spot has opened up, registers the class for me. However, I’ve hit a big snag in just the logging-in process.

Basically, I’ve been looking at the headers that are sent when I log in and try to replicate them. The problem is I keep getting an error saying “HTTP/1.1 400 Bad Request Content-Type: text/html Date: Sat, 23 Oct 2010 18:42:20 GMT Connection: close Content-Length: 42
Bad Request (Invalid Header Name)”.

I’m guessing it has something to do with Host parameter I’m setting being different from what it really is (I set it so it is elion.psu.edu, but when looking at the headers from my script it has changed back to grantbachman.com, where the script is hosted). I guess it’ll be best just to show you.
The beginning of the header I’m trying to create:

https://elion.psu.edu/cgi-bin/elion-student.exe/submit

POST /cgi-bin/elion-student.exe/submit HTTP/1.1
Host: elion.psu.edu

The beginning of the header which shows up when I run my script:

http://myDomain.com/myScriptName.php

GET /elionScript.php HTTP/1.1
Host: myDomain.com

Basically, the first line is different, the Host name is different, and it says I’m sending my info with a GET variable instead of a POST variable (even though I set curlopt_post to true). I’m basically looking for any help with altering this info such that the server accepts my script. I’m fresh out of ideas. Thanks.

Oh here’s the code I’m using:

$data = array(
    "$userIDName" => '********',
    "$passName" => '********',
    "$submitName" => 'Login+to+eLion',
    'submitController' => '',
    'forceUnicode' => '%D0%B4%D0%B0',
    'sessionKey' => "$sessionValue",
    'pageKey' => "$pageKeyValue",
    'shopperID' => '');

$contentLength = strlen($userIDName . '=*********&' . $passName . '=********&' . $submitName .'=Login+to+eLion&submitController=&forceUnicode=%D0%B4%D0%B0&sessionKey=' . $sessionValue . '&pageKey=' . $pageKeyValue . '&shopperID=');

$ch = curl_init("https://elion.psu.edu/cgi-bin/elion-student.exe/submit");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_COOKIE,'sessionKey="$sessionValue";pageKey="$pageKeyValue";BIGipServerelion_prod_pool="$prodPoolValue"');
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
    'Host: elion.psu.edu',
    'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10',
    'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    '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: 115',
    'Referer: https://elion.psu.edu/cgi-bin/elion-student.exe/launch/ELionMainGUI/Student',
    "Cookie: sessionKey=$sessionValue; pageKey=$pageKeyValue; BIGipServerelion_prod_pool=$prodPoolValue", 'Content-Type: application/x-www-form-urlencoded',
    "Content-Length: $contentLength"));
$contents2 = curl_exec ($ch);

I’t also probably important to note that when I run the script, none of the information below the ‘Keep-Alive: 115’ line is displayed when I view the header.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:23:44+00:00Added an answer on May 17, 2026 at 7:23 pm

    Seems it missing some code in your question but try this :

    1- Save your certificate on your server

    2- Try this code

    $pg = curl_init();
    // Set the form data for posting the login information
    $postData = array();
    $postData["username"] = $username;
    $postData["password"] = $password;
    
    $postText = "";
    
    foreach( $postData as $key => $value ) {
    $postText .= $key . "=" . $value . "&";
    }
    
    curl_setopt( $pg, CURLOPT_URL, $YOUR_URL );
    curl_setopt( $pg, CURLOPT_POST, true );
    curl_setopt( $pg, CURLOPT_POSTFIELDS, $postText );
    curl_setopt( $pg, CURLOPT_SSL_VERIFYPEER, true );
    curl_setopt( $pg, CURLOPT_SSL_VERIFYHOST, 2 );
    curl_setopt( $pg, CURLOPT_CAINFO, getcwd() . '/web'); //web is the exported certificate
    
    
    //curl_setopt( $pg, CURLOPT_VERBOSE, true ); // for debug 
    //curl_setopt( $pg, CURLOPT_RETURNTRANSFERT, true); // if you want a ouput
    curl_setopt( $pg, CURLOPT_COOKIEJAR, "cookies.txt" );
    curl_setopt( $pg, CURLOPT_COOKIEFILE, "cookies.txt" );
    curl_setopt( $pg, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)" );
    curl_setopt( $pg, CURLOPT_FOLLOWLOCATION, true );
    curl_setopt( $pg, CURLOPT_COOKIE, session_name() . '=' . session_id() );
    
    if( ( $response = curl_exec( $pg ) ) === false ) {
            echo '*Curl erro' . curl_error($pg) . "\n";
    }
    
    curl_close($pg)
    

    $YOUR_URL:https://elion.psu.edu/cgi-bin/elion-student.exe/launch/ELionMainGUI/Student

    The form using dynamic name so its not simple like “username” and “password”. Check on the website to know a “good” one.

    Do not forget to add others hidden field like you did in the postData array and update the cookie section too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.