EdgarsK Posted June 16, 2009 Report Share Posted June 16, 2009 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... Quote Link to comment Share on other sites More sharing options...
marcis Posted June 16, 2009 Report Share Posted June 16, 2009 Apskati curl_getinfo() un CURLINFO_HTTP_CODE option'u. Redzēsi atilbdes header'us, attiecīgi arī skatīsies vai ir bijis redirect's. Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted June 16, 2009 Author Report Share Posted June 16, 2009 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 Quote Link to comment Share on other sites More sharing options...
bubu Posted June 17, 2009 Report Share Posted June 17, 2009 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). Quote Link to comment Share on other sites More sharing options...
J0ke Posted June 17, 2009 Report Share Posted June 17, 2009 interesanti... tik kāda mārrutka pēc tik daudz redirekti vajadzīgi :> Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted June 17, 2009 Author Report Share Posted June 17, 2009 paldies bubu. j0ke: lai marinētu ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.