php,wamp,表单post获取不到数据

思顾涯 2019-05-05 11:36:23
在notepad++里面写的php文件,放到wamp/www目录下运行,在使用表单时get能获取到表单值,而post不能获取到。求大神解决
...全文
197 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
思顾涯 2019-05-05
  • 打赏
  • 举报
回复
引用 3 楼 qq_45016472的回复:
[quote=引用 2 楼 qq_45016472的回复:][quote=引用 1 楼 kang#kang的回复:]你看你的$_POST 里面有数据吗? post是需要表单传入的 或者 curl的方式 如果你form表单传入了 post还没有数据 那么你看你的$_POST有注册全局变量吗?
这是表单代码:<html><meta charset="utf-8"><head><title color="red">调查问卷</title> </head><body><form name="form1" methed="post" action="5.1.1.php"/>姓名:<input type="text" name="name"/></br>性别:<input type="radio" name="sex" value="男" checked />男 <input type="radio" name="sex" value="女"/>女</br>你的爱好:</br><input type="checkbox" name="ah1" value="sang"/>唱歌</br><input type="checkbox" name="ah2" value="dance"/>跳舞</br><input type="checkbox" name="ah3" value="drink"/>喝酒</ br><input type="checkbox" name="ah4" value="play"/>玩耍</br>请输入你的详细介绍:</br><textarea name="xxjs" cols="50" rows="5"/></textarea></br></br><input name="submit" type="submit" value="提交" align="center"/><input type="reset" value="重写" align="center"/></form></body></html>[/quote] 这个是php代码, <html>
<meta charset="utf-8">
<head>
<title>
接受调查问卷
</title>
<body>
<?php
echo $_POST["name"];
echo "你的性别是".$_GET["sex"];
?>
</body>
</head>
</html>[/quote] 运行出来是这样的,post得到的值显示警告,而get能获取到值 ( ! ) Notice: Undefined index: name in D:\wamp\www\5.1.1.php on line 9
Call Stack
# Time Memory Function Location
1 0.0005 242160 {main}( ) ..\5.1.1.php:0
你的性别是男
思顾涯 2019-05-05
  • 打赏
  • 举报
回复
引用 2 楼 qq_45016472的回复:
[quote=引用 1 楼 kang#kang的回复:]你看你的$_POST 里面有数据吗? post是需要表单传入的 或者 curl的方式 如果你form表单传入了 post还没有数据 那么你看你的$_POST有注册全局变量吗?
这是表单代码:<html><meta charset="utf-8"><head><title color="red">调查问卷</title> </head><body><form name="form1" methed="post" action="5.1.1.php"/>姓名:<input type="text" name="name"/></br>性别:<input type="radio" name="sex" value="男" checked />男 <input type="radio" name="sex" value="女"/>女</br>你的爱好:</br><input type="checkbox" name="ah1" value="sang"/>唱歌</br><input type="checkbox" name="ah2" value="dance"/>跳舞</br><input type="checkbox" name="ah3" value="drink"/>喝酒</ br><input type="checkbox" name="ah4" value="play"/>玩耍</br>请输入你的详细介绍:</br><textarea name="xxjs" cols="50" rows="5"/></textarea></br></br><input name="submit" type="submit" value="提交" align="center"/><input type="reset" value="重写" align="center"/></form></body></html>[/quote] 这个是php代码, <html>
<meta charset="utf-8">
<head>
<title>
接受调查问卷
</title>
<body>
<?php
echo $_POST["name"];
echo "你的性别是".$_GET["sex"];
?>
</body>
</head>
</html>
思顾涯 2019-05-05
  • 打赏
  • 举报
回复
引用 1 楼 kang#kang的回复:
你看你的$_POST 里面有数据吗? post是需要表单传入的 或者 curl的方式 如果你form表单传入了 post还没有数据 那么你看你的$_POST有注册全局变量吗?
这是表单代码:<html><meta charset="utf-8"><head><title color="red">调查问卷</title> </head><body><form name="form1" methed="post" action="5.1.1.php"/>姓名:<input type="text" name="name"/></br>性别:<input type="radio" name="sex" value="男" checked />男 <input type="radio" name="sex" value="女"/>女</br>你的爱好:</br><input type="checkbox" name="ah1" value="sang"/>唱歌</br><input type="checkbox" name="ah2" value="dance"/>跳舞</br><input type="checkbox" name="ah3" value="drink"/>喝酒</ br><input type="checkbox" name="ah4" value="play"/>玩耍</br>请输入你的详细介绍:</br><textarea name="xxjs" cols="50" rows="5"/></textarea></br></br><input name="submit" type="submit" value="提交" align="center"/><input type="reset" value="重写" align="center"/></form></body></html>
kang#kang 2019-05-05
  • 打赏
  • 举报
回复
你看你的$_POST 里面有数据吗? post是需要表单传入的 或者 curl的方式 如果你form表单传入了 post还没有数据 那么你看你的$_POST有注册全局变量吗?
kang#kang 2019-05-05
  • 打赏
  • 举报
回复
不客气 谁都会粗心 很正常
思顾涯 2019-05-05
  • 打赏
  • 举报
回复
引用 9 楼 kang#kang的回复:
[quote=引用 8 楼 qq_45016472 的回复:] 您方便的话看一下点进我的主页看一下另一个篇子吧,这个我没写清楚,那个有图片描述。和这个贴问题是一样的,麻烦您了
我看了一下代码 。。 气死了让你。。 !
 
<!--                            这里是method你写错了      -->
<form name="form1" methed ="POST" action="./index.php"/>

下面的代码


<?php

var_dump($_POST);
?>

<html>
<meta charset="utf-8">
<head>
    <title color="red">调查问卷</title>
</head>
<body>
    <form name="form1" method="POST" action="./index.php"/>
        姓名:<input type="text" name="name"/></br>性别:
        <input type="radio" name="sex" value="男" checked/>男
        <input type="radio" name="sex" value="女"/>女</br>
        你的爱好:</br><input type="checkbox" name="ah1" value="sang"/>唱歌</br>
        <input type="checkbox" name="ah2" value="dance"/>跳舞</br>
        <input type="checkbox" name="ah3" value="drink"/>喝酒</br>
        <input type="checkbox" name="ah4" value="play"/>玩耍</br>
        请输入你的详细介绍:</br><textarea name="xxjs" cols="50"rows="5"/></textarea></br></br>
        <input name="submit" type="submit" value="提交" align="center"/>
        <input type="reset" value="重写" align="center"/>
    </form>
</body>
</html>





这是输出: [/quote] 太感谢你了,刚刚另一个读者也给我指出了这个错误,我改了没弄好,后来解决了,本来想给你发消息说解决问题了的,可是这个APP一次最多只能回复三条,我回复不了了,实在太谢谢你们,给你们大佬点赞。谢谢,谢谢!
kang#kang 2019-05-05
  • 打赏
  • 举报
回复
引用 8 楼 qq_45016472 的回复:
您方便的话看一下点进我的主页看一下另一个篇子吧,这个我没写清楚,那个有图片描述。和这个贴问题是一样的,麻烦您了
我看了一下代码 。。 气死了让你。。 !
 
<!--                            这里是method你写错了      -->
<form name="form1" methed ="POST" action="./index.php"/>

下面的代码


<?php

var_dump($_POST);
?>

<html>
<meta charset="utf-8">
<head>
    <title color="red">调查问卷</title>
</head>
<body>
    <form name="form1" method="POST" action="./index.php"/>
        姓名:<input type="text" name="name"/></br>性别:
        <input type="radio" name="sex" value="男" checked/>男
        <input type="radio" name="sex" value="女"/>女</br>
        你的爱好:</br><input type="checkbox" name="ah1" value="sang"/>唱歌</br>
        <input type="checkbox" name="ah2" value="dance"/>跳舞</br>
        <input type="checkbox" name="ah3" value="drink"/>喝酒</br>
        <input type="checkbox" name="ah4" value="play"/>玩耍</br>
        请输入你的详细介绍:</br><textarea name="xxjs" cols="50"rows="5"/></textarea></br></br>
        <input name="submit" type="submit" value="提交" align="center"/>
        <input type="reset" value="重写" align="center"/>
    </form>
</body>
</html>





这是输出:
思顾涯 2019-05-05
  • 打赏
  • 举报
回复
您方便的话看一下点进我的主页看一下另一个篇子吧,这个我没写清楚,那个有图片描述。和这个贴问题是一样的,麻烦您了
思顾涯 2019-05-05
  • 打赏
  • 举报
回复
引用 6 楼 qq_45016472的回复:
[quote=引用 5 楼 繁华落幕、的回复:]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
 
<form action="" method="post">
姓名:<input type="text" name="name" value="<?php echo $_POST['name']?>"/>
    <input type="submit" value="提交"/>
</form>
 
</body>
</html>
 
<?php
echo '<pre>';
var_dump($_POST);
echo '</pre>';
?>
替换掉你原本的代码运行下看
好的 我试试[/quote] 会显示这个错误 ( ! ) Parse error: syntax error, unexpected '?' in D:\wamp\www\first.PHP on line 19
思顾涯 2019-05-05
  • 打赏
  • 举报
回复
引用 5 楼 繁华落幕、的回复:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
 
<form action="" method="post">
姓名:<input type="text" name="name" value="<?php echo $_POST['name']?>"/>
    <input type="submit" value="提交"/>
</form>
 
</body>
</html>
 
<?php
echo '<pre>';
var_dump($_POST);
echo '</pre>';
?>
替换掉你原本的代码运行下看
好的 我试试
繁华落幕、 2019-05-05
  • 打赏
  • 举报
回复
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
 
<form action="" method="post">
姓名:<input type="text" name="name" value="<?php echo $_POST['name']?>"/>
    <input type="submit" value="提交"/>
</form>
 
</body>
</html>
 
<?php
echo '<pre>';
var_dump($_POST);
echo '</pre>';
?>
替换掉你原本的代码运行下看

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧