ilikemath2002 Posted January 25, 2009 Share Posted January 25, 2009 I use my site as a way to remotely login to another site. Recently the site change from GET to POST, and now I have to use cURL to do it. Info about the site: - It uses post - It uses SSL My script isn't working! <?php ini_set('display_errors', 1); error_reporting(E_ALL); $user = $_POST['username']; $pass = $_POST['password']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"WEBSITEURLGOESHERE?"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,"username=" . $user . "&password=" . $pass .); $pagedata = curl_exec($ch); curl_close($ch); I've verified that the form names are correct, but should there be a ? on the end of my website URL since it's POST not GET. If not, what do I need to change to make it POST instead of GET? At the moment the script returns Invalid Username/Pass, but I know that information is correct. EDIT: Getting this error: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/site/public_html/dir This isn't related to the problem but how do I fix that? Quote Link to comment Share on other sites More sharing options...
cwarn23 Posted January 25, 2009 Share Posted January 25, 2009 I check your script and your syntax usage of the function curl_setopt() seems to be incorrect. Try the following and if it works, you can try uncommenting the commented line in the following: <?php ini_set('display_errors', 1); error_reporting(E_ALL); $user = $_POST['username']; $pass = $_POST['password']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"WEBSITEURLGOESHERE?"); //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS,"username=" . $user . "&password=" . $pass .); $pagedata = curl_exec($ch); curl_close($ch); Hope that helps. Quote Link to comment Share on other sites More sharing options...
ilikemath2002 Posted January 25, 2009 Author Share Posted January 25, 2009 Your script fixes the error, but the script itself still isn't working.(Still saying Invalid Username/Pass) This has to be a problem with the POST v.s. GET dilemma, or the SSL. Quote Link to comment Share on other sites More sharing options...
ilikemath2002 Posted January 25, 2009 Author Share Posted January 25, 2009 Apparently the curl follow thing has to be there because there is a redirect. 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.