如何让地址传值变成POST的形式,而不用表单 http://localhost/vston/member/reg_new.php?regbase=123如果我有这么一段提交,我想把这个提交改成POST的形式要怎么作呢???把传值能数变成POST的形式 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 curl啊$url = 'http://localhost/vston/member/reg_new.php';$fields_string = 'regbase=123';$ch = curl_init() ;//set the url, number of POST vars, POST datacurl_setopt($ch, CURLOPT_URL,$url) ;curl_setopt($ch, CURLOPT_POST,true) ;curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string) ;//execute post$result = curl_exec($ch) ;//close connectioncurl_close($ch) ; xmlhttphttp://www.w3schools.com/ajax/ajax_example.asp 用ajax的post方法<?php//reg_new.phpif($_POST){ echo $_POST['text'];}else{ echo $_REQUEST['text'];}?><input type="text" id="text" value="我是中国人"><input type="button" name="button" value="myAjax" onclick="post_test()"><script language="javascript">var request;function createxmlHttpRequest(){//判断浏览器类型,创建xmlHttpRequest对象 if(!request){ if(window.XMLHttpRequest){ request = new XMLHttpRequest(); }else{ request = new ActiveXObject("Microsoft.XMLHTTP"); } }}function post_test(){//post发送模式 createxmlHttpRequest(); var url = "reg_new.php"; var send = "regbase=123"; request.open("post", url); request.onreadystatechange = callback; request.setRequestHeader("content-type", "application/x-www-form-urlencoded"); request.send(send);}function callback(){//回调函数 if (request.readyState == 4){ if (request.status == 200){ alert(request.responseText); }else if(request.status == 404){ alert("该路径未找到"); }else if(request.status == 403){ alert("禁止访问"); }else{ alert("status is " + request.status); } }}</script> 服务器 --> 服务器 curl浏览器 --> 服务器 ajax 这就一全局变量,你不初始化也行,..............$_POST['regbase'] = 123;跳转到reg_new.php页面直接就可以用~~ 只能ajax来做//Ajaxfunction Ajax(){ var _xmlHttp = null; this.createXMLHttpRequest = function(){try{if (window.ActiveXObject){_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}else if (window.XMLHttpRequest){_xmlHttp = new XMLHttpRequest();}}catch(e){alert(e.name +" : " + e.message);}} this.backFunction = function(_backFunction){if(_xmlHttp.readyState == 4){if(_xmlHttp.status == 200){_backFunction(_xmlHttp.responseText);}}_xmlHttp.onreadystatechange = null;} this.doPost = function(_url,_parameter,_backFunction){try{_xmlHttp.open("POST",_url, false);_xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");_xmlHttp.send(_parameter);}catch(e){alert(e.name +" : " + e.message);}} this.doGet = function(_url,_parameter,_backFunction){try{var _random = Math.round(Math.random()*10000);_xmlHttp.open("GET", (_url+"?random=" +_random +"&" + _parameter), false);_xmlHttp.send(null);}catch(e){alert(e.name +" : " + e.message);}} this.ajaxRequest = function(_url,_parameter,_method,_backFunction){try{this.createXMLHttpRequest();if(_method.toLowerCase() == "post"){this.doPost(_url,_parameter,_backFunction);}else{this.doGet(_url,_parameter,_backFunction);}try{_xmlHttp.onreadystatechange = this.backFunction(_backFunction);}catch(err){}}catch(e){alert(e.name+" : "+e.message);}}}function cDB(work,tab){ if(work=='' || tab==''){return false;} var url = "Sys_Data.php?work=cdata&typ="+work+"&tab="+tab; var parameter = ""; var method = "post"; new Ajax().ajaxRequest(url,parameter,method,callBack); function callBack(xml){ _g('t1').innerHTML=(xml.replace("\"","")); cHidden('PopMenu',0,1); }} 补充下服务器 --> 服务器 curl 或者socket 求解:并发执行远程telnet到多个服务器查询硬盘,这个怎样实现 读取 excel 日语数据时 出现乱码 如何解决啊? 知名出版社征ASP.NET和PHP高手写书 php交流群,新建200人高级群:66589844 如何获取表格中复选框选中行的数据? php 类对象通过函数名字符串调用该方法 帮我看下这段代码有什么错误? 大家来帮帮我啊!急 用PHP如何读取int(10)字段 求PHP取得系统信息的函数,CPU+内存使用+磁盘空间 匹配中文的正则表达式怎么写 这句php运行怎么出错了?
$fields_string = 'regbase=123';
$ch = curl_init() ;
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL,$url) ;
curl_setopt($ch, CURLOPT_POST,true) ;
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string) ;
//execute post
$result = curl_exec($ch) ;
//close connection
curl_close($ch) ;
//reg_new.php
if($_POST){
echo $_POST['text'];
}else{
echo $_REQUEST['text'];
}
?><input type="text" id="text" value="我是中国人">
<input type="button" name="button" value="myAjax" onclick="post_test()"><script language="javascript">
var request;
function createxmlHttpRequest(){//判断浏览器类型,创建xmlHttpRequest对象
if(!request){
if(window.XMLHttpRequest){
request = new XMLHttpRequest();
}else{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
}
}function post_test(){//post发送模式
createxmlHttpRequest();
var url = "reg_new.php";
var send = "regbase=123";
request.open("post", url);
request.onreadystatechange = callback;
request.setRequestHeader("content-type", "application/x-www-form-urlencoded");
request.send(send);
}function callback(){//回调函数
if (request.readyState == 4){
if (request.status == 200){
alert(request.responseText);
}else if(request.status == 404){
alert("该路径未找到");
}else if(request.status == 403){
alert("禁止访问");
}else{
alert("status is " + request.status);
}
}
}
</script>
浏览器 --> 服务器 ajax
..............
$_POST['regbase'] = 123;跳转到reg_new.php页面直接就可以用~~
function Ajax(){
var _xmlHttp = null;
this.createXMLHttpRequest = function(){try{if (window.ActiveXObject){_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}else if (window.XMLHttpRequest){_xmlHttp = new XMLHttpRequest();}}catch(e){alert(e.name +" : " + e.message);}}
this.backFunction = function(_backFunction){if(_xmlHttp.readyState == 4){if(_xmlHttp.status == 200){_backFunction(_xmlHttp.responseText);}}_xmlHttp.onreadystatechange = null;}
this.doPost = function(_url,_parameter,_backFunction){try{_xmlHttp.open("POST",_url, false);_xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");_xmlHttp.send(_parameter);}catch(e){alert(e.name +" : " + e.message);}}
this.doGet = function(_url,_parameter,_backFunction){try{var _random = Math.round(Math.random()*10000);_xmlHttp.open("GET", (_url+"?random=" +_random +"&" + _parameter), false);_xmlHttp.send(null);}catch(e){alert(e.name +" : " + e.message);}}
this.ajaxRequest = function(_url,_parameter,_method,_backFunction){try{this.createXMLHttpRequest();if(_method.toLowerCase() == "post"){this.doPost(_url,_parameter,_backFunction);}else{this.doGet(_url,_parameter,_backFunction);}try{_xmlHttp.onreadystatechange = this.backFunction(_backFunction);}catch(err){}}catch(e){alert(e.name+" : "+e.message);}}
}
function cDB(work,tab){
if(work=='' || tab==''){return false;}
var url = "Sys_Data.php?work=cdata&typ="+work+"&tab="+tab;
var parameter = "";
var method = "post";
new Ajax().ajaxRequest(url,parameter,method,callBack);
function callBack(xml){
_g('t1').innerHTML=(xml.replace("\"",""));
cHidden('PopMenu',0,1);
}
}
补充下
服务器 --> 服务器 curl 或者socket