Rt.
I just have to let PHP impersonate the HTTP POST to send NVP to the other local files.
Instead of returning any value,
How to configure the parameters?
$ch = Curl_init ();
curl_setopt ($ch, Curl_url, $url);
curl_setopt ($ch, curl_post,true);
curl_setopt ($ch, Curl_postfields, $postfields);
...
What parameters do you need to configure in addition to these few?
Seeking the Great God
Reply to discussion (solution)
Do not return a value? You don't care if he returns, all right?
Do not return a value? You don't care if he returns, all right?
Yes, that's what I do:
function HttpPost ($url, $postvalue)
$ch = Curl_init ();
curl_setopt ($ch, Curl_url, $url);
curl_setopt ($ch, curl_post,true);
curl_setopt ($ch, Curl_postfields, $postfields);
curl_setopt ($ch, Curl_returntransfer, 0);
Curl_exec ($ch);
Curl_close ($ch);
}
And then inside the a.php.
$url = "http://mysite.com/b.php";
$postvalue = "Name1=one&name2=two";
HttpPost ($url, $postvalue);
And then inside the b.php,
Print_r ($_post);
The result is that the array output in b.php has nothing.
Do you see any missing links?
It's OK to accept or not come out.
It's OK to accept or not come out.
But the code above me is almost like that.
But the test results do not receive the passed value,
Can you help me see if there's something missing?
Too many mistakes, huh?
function HttpPost ($url, $postvalue) { $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_post, true); curl_setopt ($ch, Curlopt_postfields, $postvalue); curl_setopt ($ch, Curlopt_returntransfer, 0); Do not return data should be changed to 1 curl_exec ($ch); Curl_close ($ch);}
In the a.php inside does not output, you in the b.php output what thing, will not see ...
In the a.php inside does not output, you in the b.php output what thing, will not see ...
Why, can you say something specific?
Too many mistakes, huh? PHP Code
function HttpPost ($url, $postvalue) {
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_post, true);
curl_setopt ($ch, Curlopt_postfields, $pos ...
Ah, what's wrong with the other returntransfer?
Thank you for pointing out that
Also, I used the HttpPost () function in a script, and then JS jumps to the page of the target URL,
The target URL is used to test the Print_r ($POST),
But after the jump, there's nothing in the page. Output, $post array is empty
You know what's going on?
In fact, I mean to pass data between two files on the server side, but don't want to use cookie/session or memcache,
It's a good idea to jump to another file while Curl is sending a post, and deliver the data, like an HTML post form,
Like what
if ($verify) {
Validation successful
Post ($url, $postvalue);
?//Send post information at the same time, the page jumps to the destination,
}
I hope so.
If you can't do that, you can only use PHP to breathe out.
Form and then JS forced to commit, but that data will be displayed in the client source code, and after the refresh will have a form prompt.
Direct output
Curl_exec ($ch);
To see what the result is ... Did you get dizzy ...? I don't know if that's the end of the head. ==|
Feel the LZ approach is very strange ah, with the HTTP protocol for file content interaction ...
The constant parameters are all wrong!
It's curlopt_xxx.
Not curl_xxx.
You do not write this one in effect.
Landlord, I am the same as you think, now you achieve it?