cURL/login help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

neoaddict
Forum Commoner
Posts: 44
Joined: Thu Jan 12, 2006 12:28 pm

Post by neoaddict »

Would I just put normal headers (eg. header(Something: Something);) or how else would I put it?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

rtfm and use brain ;)

Where should the headers go to?

http://www.php.net/header : returns http status headers to your visitor

Or do you want to send those headers (with your http request) to the neopets site? :P
neoaddict
Forum Commoner
Posts: 44
Joined: Thu Jan 12, 2006 12:28 pm

Post by neoaddict »

To the Neopets site obviously. :P
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Well then, show us what you've come up with.
neoaddict
Forum Commoner
Posts: 44
Joined: Thu Jan 12, 2006 12:28 pm

Post by neoaddict »

Code: Select all

<?php

$postfields = array ('username' => 'TEST',
                              'password' => 'TEST',
                              'destination' => 'TEST');

$goodpost = urlencode ($postfields);

$url = 'http://neopets.com/login.phtml?';
$goodurl = urlencode ($url);
                             
$ch = curl_init();

header('Content-Type: application/x-www-form-urlencoded');
header('Referer: http://neopets.com/hi.phtml');

curl_setopt($ch, CURLOPT_URL, $goodurl);
curl_setopt($ch, CURLOPT_POST, true);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $goodpost);

//$something = file_get_contents("http://neopets.com/stockmarket.phtml");
//$something = preg_match("#<marquee>(.*)<\/marquee>#i", $retrievedhtml, $match);

$output = curl_exec($ch);
echo $output;

echo curl_error($ch);

curl_close($ch);

?>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Not to be harsh, but i don't think you're ready to write a script as the one that you want.
Might want to start with something simpler first.
neoaddict
Forum Commoner
Posts: 44
Joined: Thu Jan 12, 2006 12:28 pm

Post by neoaddict »

Like what?
Post Reply