drillbitt Posted March 3, 2009 Share Posted March 3, 2009 Hi Guys, I'm trying to POST data to a login.php script, and am totally stuck! I have a members area which when logged in, I want my members to be able to be able to access another script within it. Unfortunately the 3rd party script is ioncube encoded, but uses a login.html template to submit the log on details. Ive managed to ##HASH## together a way that the users details match the details of my membership script, so I entered $Username & $password as the default values of the login.html, with the hope that by just creating a link to 3rdpartyscript/login.php it would replace the details and log the user in. This worked (in a fashion) but it seems to me It would be easier to use the cURL function... Which is where I become totally lost! I created logincurl.php as below: <?php //create array of data to be posted $post_data['email'] = '<?php echo $username; ?>'; $post_data['password'] = '<?php echo $password; ?>'; //create the final string to be posted using implode() $post_string = implode ('&', $post_items); //create cURL connection $curl_connection = curl_init('http://wizardresponder.com/v2/members/login.php'); //set options curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); //set data to be posted curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); //perform our request $result = curl_exec($curl_connection); //show information regarding the request print_r(curl_getinfo($curl_connection)); echo curl_errno($curl_connection) . '-' . curl_error($curl_connection); //close the connection curl_close($curl_connection); which I (presume) I then point the link in the members area to, and was sorta assuming that would log them on... but all I get is Warning: implode() [function.implode]: Invalid arguments passed in /home/randp/public_html/v2/logincurl.php on line 6 Array ( [url] => http://wizardresponder.com/v2/members/login.php [content_type] => text/html [http_code] => 200 [header_size] => 262 [request_size] => 211 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.014451 [namelookup_time] => 0.002115 [connect_time] => 0.002393 [pretransfer_time] => 0.00241 [size_upload] => 0 [size_download] => 4564 [speed_download] => 315825 [speed_upload] => 0 [download_content_length] => 4564 [upload_content_length] => 0 [starttransfer_time] => 0.014373 [redirect_time] => 0 ) 0- So that didn't work at all... Am I totally missing the point here?? I thought I'd then have a go at using cURL to create the account in the 3rdparty script, so I tried this: <?php //create array of data to be posted $post_data['package'] = 'Standard'; $post_data['packkey'] = '4fbb470fe39d70d3705e8447bd2223'; $post_data['email'] = '<?php echo $username; ?>'; $post_data['password'] = '<?php echo $password; ?>'; $post_data['fname'] = 'fname'; $post_data['lname'] = 'lname'; $post_data['address'] = 'address'; $post_data['city'] = 'city'; $post_data['state'] = 'state'; $post_data['zip'] = 'zip'; $post_data['country'] = 'country'; $post_data['website'] = 'website'; $post_data['weburl'] = 'weburl'; $post_data['action'] = 'Create Account'; //create the final string to be posted using implode() $post_string = implode ('&', $post_items); //create cURL connection $curl_connection = curl_init('http://wizardresponder.com/v2/newuser/index.php'); //set options curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); //set data to be posted curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); //perform our request $result = curl_exec($curl_connection); //show information regarding the request print_r(curl_getinfo($curl_connection)); echo curl_errno($curl_connection) . '-' . curl_error($curl_connection); //close the connection curl_close($curl_connection); ?> but just got back: Warning: implode() [function.implode]: Invalid arguments passed in /home/randp/public_html/v2/mycurl.php on line 18 Array ( [url] => http://wizardresponder.com/v2/newuser/index.php [content_type] => text/html [http_code] => 200 [header_size] => 262 [request_size] => 211 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.013726 [namelookup_time] => 0.006687 [connect_time] => 0.007158 [pretransfer_time] => 0.007169 [size_upload] => 0 [size_download] => 1548 [speed_download] => 112778 [speed_upload] => 0 [download_content_length] => 1548 [upload_content_length] => 0 [starttransfer_time] => 0.013641 [redirect_time] => 0 ) 0- All im tring to do is create a link from the members area that when clicked, automatically logs the user into the other script without them having to re-enter their details...And its driving me crazy!! If anyone could point me in the right direction, that't be so cool! Quote Link to comment Share on other sites More sharing options...
samshel Posted March 3, 2009 Share Posted March 3, 2009 $post_string = implode ('&', $post_items); should be $post_string = implode ('&', $post_data); Quote Link to comment Share on other sites More sharing options...
drillbitt Posted March 4, 2009 Author Share Posted March 4, 2009 $post_string = implode ('&', $post_items); should be $post_string = implode ('&', $post_data); Cool...! So that gets rid of the error message... But now Im lost as to what I do next! I'm assuming logincurl.php has posted the data to the other script... I just don't understand how I get the user to go there now? Do I need to set up a redirect or something? Cheers Quote Link to comment Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 if this post sets the session, u may try to redirect using header(), but i m not sure.. Quote Link to comment Share on other sites More sharing options...
drillbitt Posted March 4, 2009 Author Share Posted March 4, 2009 No thats not working.... :-\ 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.