也许这是声音很愚蠢,但我想制作一个页面,当用POST数据调用它时可以给出一些结果。
假设我有一个带有后期数据验证的a.php,它可以从外部服务器接收发布数据。
if ((isset($_POST['authKey'])) && (isset($_POST['cmd'])) && ($_POST['authKey']==$this->key) && ($_POST['cmd']=='hello')) { if (in_array($_SERVER['HTTP_REFERER'], $this->trusted)) echo 'hello world'; }如何让b.php通过发送POST数据来获取hello world 。 谢谢..抱歉我的英语太差了。
maybe this is sound's stupid but i want to make a page that can give some result when it is being called with a POST data..
lets say i have a.php with post data validation which can receive post data from outer server.
if ((isset($_POST['authKey'])) && (isset($_POST['cmd'])) && ($_POST['authKey']==$this->key) && ($_POST['cmd']=='hello')) { if (in_array($_SERVER['HTTP_REFERER'], $this->trusted)) echo 'hello world'; }how to make b.php can get hello world by sending POST data. Thank you.. Sorry my English is so bad.
最满意答案
您可以在b.php上拥有HTML表单
<form action="b.pbp" method="post"> <input name="authKey"> <input name="cmd"> <button>Make request</button> </form>您可以从b.php发出ajax请求
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { alert(xhttp.responseText); } }; xhttp.open("POST", "b.php", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send('authKey=x&cmd=y');您可以从b.php http://php.net/manual/en/book.curl.php在服务器端发出cUrl请求
You can have an HTML FORM on b.php
<form action="b.pbp" method="post"> <input name="authKey"> <input name="cmd"> <button>Make request</button> </form>You can make an ajax request from b.php
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { alert(xhttp.responseText); } }; xhttp.open("POST", "b.php", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send('authKey=x&cmd=y');You can make a cUrl request on the server side from b.php http://php.net/manual/en/book.curl.php
更多推荐
发布评论