php表单怎样提交到当前页面,并用$_POST获取其值

php表单怎样提交到当前页面,并用$_POST获取其值,第1张

<php

$username=$_POST['username'];

>

<form action="" ><input type="text" name="username"><input type="submit" name="submit" value="提交"></form>

form的action属性留空的话就直接提交到当前页面了 后台直接$_POST获取前台传过来的表单域啊

在表单页面先把数组给序列化,比如json,xml或自定义的字符串如"1,2,3,4"

然后用一个<input name="myArray" value="1,2,3,4">值就提交给php的$_POST["myArray"]后,

再在php反序列化成php的数组

这种情况你可以通过raw的形式获取内容的,比如用php://input流的形式。

$content = file_get_contents('php://input');

//$content就是你想要的内容了。

<form action="3php" method="POST">

主机地址:<input name="num" type="text" /><br />

<input name="xinxi" type="submit" value="下一步" />

</form>

$data = file_get_contents("php://input");

if($data == null){

$data = $GLOBALS['>

jQuerypost( url, [data], [callback], [type] ) :

相当于无刷新

$post('selectleixingphp',{getleimu:getleimu}); //提交数据到页面

locationhref="selectleixingphp"; //跳转到页面

上述两部完全是分开的,没有任何关系,你先提交数据到那个页面了,然后你再打开这页面(重新打开),肯定是获取不到值得。

getleimu=$("#selectleimu option:selected")text();

windowlocationhref="selectleixingphp?getleimu="+getleimu;

selectleixingphp页面用$_GET获取参数

$fields = array('a','b','c','d');//你的字段

foreach($fields as $val){

if(!empty($_POST[$val])){

$data[$val] = in($_POST[$val]);

}

}

以上就是关于php表单怎样提交到当前页面,并用$_POST获取其值全部的内容,包括:php表单怎样提交到当前页面,并用$_POST获取其值、PHP $_POST获取参数问题、通过POST直接提交一个参数值 没有参数名 php该如何获取其值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9580226.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存