What is the actual task here? Looks to me like you're trying to log in to /login.aspx, then proceed on to some login with php in another system, is that correct?
In any application - perl, ASP, PHP, it doesn't matter - when you submit data, you must return a response. The "two seconds or so" is probably the curl connection doing it's thing. You should be able to do something like this:
// compose your curl post string, like you're doing
// curl it.
//
parse curl result (below)
// - If the curled login fails, output an error (and wisely, the login form again), EXIT
// - if the curled login succeeds
// -- Post your values to the second script
// --- if the second login fails, see above, output error and form, EXIT
// return a response, login was successful. You can display your PARSED $results here, script ends, no need to exit.
Does anyone have any ideas on a better way to take the $result and render it another way?
STRING(800)
Are you actually doing anything with the curl? Generally this is a delimited or XML string, and you have to pick it apart - the reverse of what you're doing to create your curl data string. You can probably store these directly in $_POST, but be careful it doesn't stomp on any current $_POST values. For example, many curl-able locations and API's return a query string:
//authResp=true&user=rocknbil&last-login=2012-01-01&bleah=blah
$post_pairs = explode('&',$result);
foreach ($postpairs as $pair) {
list($k,$v) = explode('=',$pair);
$_POST[$k] = urldecode($v);
}
If it's XML, you'd use some method to step through the tree.
Using the above wire frame, after parsing out $result to get at authResp, you'd only need to check it if it's not auth'ed.
if (! isset($_POST["authResp"]) or ($_POST["authResp"] != "true")) { // should be true or false, shouldn't it?
// print error, output login form
}
// Otherwise you proceed to second login and print a response