Jump to content
php.lv forumi

Curl - vai spēj sekot redirektam? kā?


EdgarsK

Recommended Posts

Sveiki,

 

index.php

   extract($_POST);
   $fields = array(
   'username'=>urlencode("username"),
   'password'=>urlencode("password")
   );
   foreach($fields as $key=>$value) { $fields_string.=$key.'='.$value.'&'; }
   rtrim($fields_string,'&');

   $ch = curl_init();
   curl_setopt($ch,CURLOPT_URL,"http://www/post.php");
   curl_setopt($ch,CURLOPT_POST,count($fields));
   curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
   curl_setopt($ch,CURLOPT_REFERER,"http://www");
   $var=curl_exec($ch);
   curl_close($ch);
   echo $var;

post.php

if($_POST["username"]&&$_POST["password"]) {
...
 $_SESSION["succ"]=true;
 Header("Location: success.php");
...
}else echo "Problems (1)";

success.php

if($_SESSION["succ"]) echo "Aproved"; else echo "Problems (2)";

 

Notiek sekojošais.

atverot index.php nekā neparādās.

Jautājums - Vai index.php padotais curl atverot post.php izseko arī uz success.php ? ja manā kodā nav norādītas kādas opcijas (curopt), lūdzu padalieties zināšanās...

Link to comment
Share on other sites

ehh.. tas rāda 200 success kodu :/

Lieta ir sekojoša

 

1. index.php padod post uz post.php

2. post.php parbauda vai viss ir kartiba un ja ir iet uz success.php

3. caur curl man saka ka nav pareizs kods (capcha)

4. nelietojot curl, bet izmantojot parastu <form..input type=sub></form>... capcha nostrada un viss strada

Link to comment
Share on other sites

Varbūt vajag attiecīgu opciju iespējot?

http://lv.php.net/manual/en/function.curl-setopt.php

CURLOPT_FOLLOWLOCATION TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...