dtdetu Posted November 15, 2008 Share Posted November 15, 2008 hello i am trying to make a post script but somehow it doesnt work, can u check and tell me what the problem is. The form i am posting is this : <form method='POST' action=''><input type='number' name='amount' id='amount'> <input type=submit name='send' id='send' value='Send'></form> This code posts the data but it brakes the page, i mean when i check result.htm half of the page isnt there. curl_setopt ($ch, CURLOPT_URL, 'http://site.com/page.php'); curl_setopt ($ch, CURLOPT_REFERER, 'http://site/page.php'); curl_setopt ($ch, CURLOPT_POST, TRUE); curl_setopt ($ch, CURLOPT_POSTFIELDS, "amount=1&send=Send"); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec ($ch); file_put_contents("result.htm", $result); This code doesnt even post. curl_setopt ($ch, CURLOPT_URL, 'http://site.com/page.php'); curl_setopt ($ch, CURLOPT_REFERER, 'http://site/page.php'); curl_setopt ($ch, CURLOPT_POST, TRUE); curl_setopt ($ch, CURLOPT_POSTFIELDS, "amount=1"); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec ($ch); file_put_contents("result.htm", $result); Quote Link to comment https://forums.phpfreaks.com/topic/132830-solved-curl-help-please/ Share on other sites More sharing options...
cunoodle2 Posted November 15, 2008 Share Posted November 15, 2008 There is a good chance there might be a redirect in there, a time out issue or possibly something checking for a cookie. I'd try the following additions... <?php ######### Set up field values ######### $fields = ""amount=1&send=Send"; $agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"; $ref = "http://site/page.php"; ######### Prepare curl settings and variables ######### $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, "http://site/page.php"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); //create a cookie curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); curl_setopt($ch, CURLOPT_MAXREDIRS, 4); //this sets a maximum on the number of redirects curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); //this will allow you to follow a redirect curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_TIMEOUT, 120); //increase the timeout curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_REFERER, $ref); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); //setting this to 1 makes it display ON screen. Setting it to zero does not. $buffer = curl_exec($ch); curl_close($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/132830-solved-curl-help-please/#findComment-690847 Share on other sites More sharing options...
dtdetu Posted November 15, 2008 Author Share Posted November 15, 2008 it posts but also removes some codes from the post page, its about fields i think, if i send $fields = "amount=1"; it doesnt post but doesnt break the page also , does anyone have any idea about this? it removes from the beginning of the page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="expires" content="0"> --> <title>title</title> <!--<link href="/css.dcss?css=s" rel="stylesheet" type="text/css"> <link href="/css.dcss" rel="stylesheet" type="text/css">--> <script type="text/javascript" src="js.js"> </script> <!--<script src="js2.js" language="JavaScript" type="text/javascript"></script>--> <style type="text/css"> <!-- @import url("a.css"); --> </style> <script type="text/javascript"> <!-- var border = RUZEE.ShadedBorder.create({ corner:8, shadow:16, border:2 }); //--> </script> <script language="JavaScript" type="text/javascript"> <!-- function breakout_of_frame() { if and some code from the end of the page, what does cause this anyone know? Quote Link to comment https://forums.phpfreaks.com/topic/132830-solved-curl-help-please/#findComment-690855 Share on other sites More sharing options...
dtdetu Posted November 16, 2008 Author Share Posted November 16, 2008 any help please Quote Link to comment https://forums.phpfreaks.com/topic/132830-solved-curl-help-please/#findComment-691200 Share on other sites More sharing options...
thebadbad Posted November 16, 2008 Share Posted November 16, 2008 Tell me the URL of the page, and I'll try the script out and see what I get. Quote Link to comment https://forums.phpfreaks.com/topic/132830-solved-curl-help-please/#findComment-691205 Share on other sites More sharing options...
dtdetu Posted November 16, 2008 Author Share Posted November 16, 2008 ok i was running the script from cmd now it works when i uploded it to web server, thanks Quote Link to comment https://forums.phpfreaks.com/topic/132830-solved-curl-help-please/#findComment-691237 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.