I am a php noob and I have tried a few things and nothing so far has worked.

I need to find some php code that allows me to do an http post and return the results into an array so I can parse the results for a string.

The problems I have are file get content is not enabled on the server, CURL is not installed on the server and I cant install anything on the server.

I am creating session variables from the form input then passing those variables into a php transaction to post to the site and verify the transaction results.

eg:

<?php
// start the session
session_start();
header("Cache-control: private");
$username = $_POST;
$password = $_POST;
$_SESSION = $username;
$_SESSION = $password;
?>


Next step I need to actually login behind the scenes with the php post and parse the results for the status (This is where I am losing the whole thing I cant seem to get this done)

Any ideas anyone ??

First, I would not suggest taking POST variables (or $_GET or $_REQUEST etc..) and put them straight into sessions for use later, I would suggest you look into checking/sanitizing the results to ensure that they are what is expected. Especially if you are then using these values to query a database.

Can you post the actual code that is causing the problem? Your post indicates that it is the code after this that is causing the problem..

Also, try to use code tags, makes it easier for us to separate the code from your question.

This is what I tried using but no help

<?php
$content = '';
$flag = false;
$post_query = 'username=$_SESSION&password=$_SESSION';
$post_query = urlencode($post_query) . "\r\n";
$host = 'www.somesite.com';
$path = '/somefolder/someapp.php';
$fp = fsockopen($host, '80');
// This is plain HTTP; for HTTPS, use
// $fp = fsockopen($host, '443');
if ($fp) {
fputs($fp, "POST $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-length: ". strlen($post_query) ."\r\n\r\n");
fputs($fp, $post_query);
while (!feof($fp)) {
$line = fgets($fp, 10240);
if ($flag) {
$content .= $line;
} else {
$headers .= $line;
if (strlen(trim($line)) == 0) {
$flag = true;
}
}
}
fclose($fp);


}



echo $content;
echo $headers;


?>

as for the session issue I run a session destroy if the validation fails.

However I have a new wrinkle how in the world do I get to authenticate the browser session now I have determined the values are correct

ok now I need help with my preg match

if(preg_match("/The+username+or+password+is+not+valid/i",$buf))
{
do action
}
else 
{
do some other action
}

I really dont even know if that is correct :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.