cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Change URL location on CURL requests?

From: Alessandra <alessandra.bilardi_at_gmail.com>
Date: Mon, 15 Mar 2010 13:57:42 +0100

Hi all,
I read more forum and tutorial about curl post and changing URL
location.. but I think that something escapes me..
I have got a form (https://domain1/page.html) that I would like:
* mask it with my form (https://domain2/page.html)
* post all fields into original form (https://domain1/page.html)
* return thank you page about original form
(https://domain1/page.html) when I submitted with my form
(https://domain2/page.html)

https://domain1/page.html has got a form tag:
<form method="post" id='signup' onsubmit="return validate_form();">
function javascript returns true.
if I filled in all fields and I submitted it, browser returns thank
you page into same url page: https://domain1/page.html

I create my form into https://domain2/page.html
that recall https://domain2/my.php that post fields by this code:

[code]
 ..
 $url = "https://domain1/page.html";
 $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_POST, count($postdata));
 curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
 curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 $result = curl_exec($ch);
 ..
[/code]

if I filled in all fields about my form (https://domain2/page.html)
and I submitted it, browser returns original form page
(https://domain1/page.html) with all fields filled and not thank you
page.
I tested more curl lib options adding each option at a time:

[code]
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
 curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
 curl_setopt($ch, CURLOPT_FAILONERROR, 0);
 curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
[/code]

I checked safe and basedir options, curl lib errors and url info:

[code]
 .. previous code..

 if(!ini_get('safe_mode') && !ini_get("open_basedir")) {
  echo "n safe, n basedir: CURLOPT_FOLLOWLOCATION, true";
 } elseif(!ini_get("open_basedir")) {
  echo "y safe, n basedir";
 } elseif(!ini_get('safe_mode')) {
  echo "n safe, y basedir";
 } else {
  echo "y safe, y basedir";
 }

 $error_no = curl_errno($ch);
 $error_wd = curl_error($ch);
 $url_info = curl_getinfo($ch);

 $result = curl_exec($ch);
 curl_close($ch);
 $strg = "";

 foreach ($url_info as $k => $v) {
  $strg .= "$k = $v; ";
 }

 if ($error_no == 0) {
  $error = '<br/>File uploaded succesfully
('.$error_wd.'['.$error_no.']): '.$strg.'.';
 } else {
  $error = '<br/>File upload error ('.$error_wd.'['.$error_no.']): '.$strg.'.';
 }

 echo $error;
[/code]

And I obtainted that:
* php runs with safe_mode and open_basedir ON
* posting by curl lib has got error:
File uploaded succesfully ([0]): url = https://domain1/page.html;
content_type = text/html; http_code = 200; header_size = 393;
request_size = 175; filetime = -1; ssl_verify_result = 0;
redirect_count = 0; total_time = 1.60061; namelookup_time = 0.002403;
connect_time = 0.143216; pretransfer_time = 0.438166; size_upload =
4552; size_download = 51836; speed_download = 32385; speed_upload =
2843; download_content_length = 0; upload_content_length = 4552;
starttransfer_time = 0.589802; redirect_time = 0; .1

I don't understand where/what I must to do because browser returns me
thank you page: https://domain1/page.html
can you help me about?

Alessandra.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2010-03-15