0

I think, we would need cURL only for cross domain applications. I mean if I use pages stored under same domain then I should simply use POST rather than cURL.

Is this right?

Also,

For example: how do i check if username=1 and password=2 in check.php page and return TRUE or FALSE?

<?  
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://www.mysite.com/check.php'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
curl_setopt(CURLOPT_USERPWD, '[username]:[password]') 

$data = curl_exec(); 
curl_close($ch); 
 ?>
4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by theighost
0

Although the answer to your second question may vary depending on if you want to do cross-site processing, to post a form to another domain, just set the action field in the form like the following:

<form action='http://www.you_post_to_domain.com/index.php' method='post'>

Hope that helps answer your question.

0

As you can see i have used curl_setopt(CURLOPT_USERPWD, '[username]:[password]'); in my example.

I say, what code do i write in check.php to find out what username and password received.

0

well, What I can think of is an ajax solution, you can make an ajax function that links to the chech.php and gives the pass and username.

In the check.php you can write: if(($user==1)&&($pass==2))
{print true;}
else
{print false;}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.