Tryed this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://site/takelogin.php');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=USER&password=PASS');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
curl_close ($ch);
Everything starts in login.php but form goe’s to takelogin.php, and if username and password correct it redirect’s to acc.php For better understand posting part of login.php html side which i think important:
<form action="takelogin.php" id="signup" method="post">
<input id="username" name="username" type="text" maxlength="25" value="">
<input id="password" name="password" type="password" maxlength="60" value="">
<input name="commit" type="submit" value="Login">
<input type="hidden" name="returnto" value="/acc.php"
Even in browser url bar tryed enter:
http://site/takelogin.php?returnto=acc.php&username=USER&password=PASS
No luck.
What i’m missing in mine curl script ?
If you want curl to follow php redirects you need to use this:
But you also have the “returnto” field in your form, which you don’t use in your curl script. Do you need that variable, or is it optional?