Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing POST variable from another site

Status
Not open for further replies.

nedstar1

IS-IT--Management
Mar 2, 2001
127
US
Hi folks,

I'm working on allowing someone to connect to my site from their intranet. By clicking on a link on their intranet page, a POST variable called auth is sent to my site, specifically, to a logon processor page login_referred.php.

Now, the POST'ed auth variable actually has a pair of values in it consisting of my login credentials - the email address,a nd the username. So I have this code:

Code:
<?php
session_start();
include("include_nc.php");
//$auth=("HODGS01,ned@company.com");
extract($_POST);
$referral = explode(",",$auth);
$username = $referral[1];
$pwd = $referral[0];

Now, this would seem to be working, but I can't be sure. If I uncomment the line where I set a value for $auth, it works fine, redirects and logs me in. If I comment it out as shown, it does not work.

I HOPE that my issue is with passing the auth over from the previous page. I made a dummy page with a button and a hidden field. I named the hidden field $auth and put the same value pair in it, dropped that hidden field and submit button on a form with action as login_referred.php, and tested it - nothing.

I thnk I'm not doing somethign right in my testing. How do I send over a POST variable "auth" with my selected values in it? How do I retireve those values?

What have I done wrong?

I'll take a man apge as always.

Regards,
and TIA,
Nedstar1
 
How are you sending it?
Have you tried a print_r($_POST) to see if it is even populated on the login page? My bet is that its empty.
 
That's the thing - I'm not the one sending it. What I need to do is to find out HOW to send it, so I can test my code out. All I know is that it is called auth, that it is a POST variable, and that it is sent in the header.

On my auth-test.php page, I inserted that small form. On the target page, I inserted this code from the PHP FAQs here:
Code:
/* 	RawPOST V1.0
	(c)2002 Danny Shepherd <danny@kyboshed.com>
	[URL unfurl="true"]http://www.kyboshed.com[/URL]
	
	Sends bugs and suggestions to danny@kyboshed.com
	
	This text must not be removed
*/
	
function rawPOST($postData,$arrayName="")
{
	$postString="";
	foreach ($postData as $key=>$value)
	{
		if (is_array($value))
		{
			if (!empty($arrayName))
				$key=$arrayName."[$key]";
				
			$postString.=rawPOST($value,$key);
		}
		else
		{
			if (empty($arrayName))
				$postString.="$key=$value ";
			else
				$postString.=$arrayName."[$key]=$value ";	
		}
	}
	
	return $postString;	
}
	
if (!empty($_POST))
{
	echo rawPOST($_POST);
}

?>

That returns this:

Code:
login= password= auth=password,login Submit=Submit

So that stuff seems to be passing over fine, right? So if I change the name of auth to $auth,a nd plug in the values for my authenticated user,a nd redirect to the login_referred.php, it should work.
Oh. It does. Brilliant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top