在notepad++里面写的php文件,放到wamp/www目录下运行,在使用表单时get能获取到表单值,而post不能获取到。求大神解决

解决方案 »

  1.   

    你看你的$_POST 里面有数据吗? post是需要表单传入的 或者 curl的方式 如果你form表单传入了 post还没有数据 那么你看你的$_POST有注册全局变量吗?
      

  2.   

    这是表单代码:<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>
      

  3.   

    这是表单代码:<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>
    这个是php代码,
    <html>
    <meta charset="utf-8">
    <head>
    <title>
    接受调查问卷
    </title>
    <body>
    <?php 
    echo $_POST["name"];
    echo "你的性别是".$_GET["sex"];
    ?> 
    </body>
    </head>
    </html>
      

  4.   

    这是表单代码:<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>
    这个是php代码,
    <html>
    <meta charset="utf-8">
    <head>
    <title>
    接受调查问卷
    </title>
    <body>
    <?php 
    echo $_POST["name"];
    echo "你的性别是".$_GET["sex"];
    ?> 
    </body>
    </head>
    </html>
    运行出来是这样的,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
    你的性别是男
      

  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>';
    ?>替换掉你原本的代码运行下看
      

  6.   

    好的       我试试
    会显示这个错误
    ( ! ) Parse error: syntax error, unexpected '?' in D:\wamp\www\first.PHP on line 19
      

  7.   


    我看了一下代码 。。 气死了让你。。 ! 
     
    <!--                            这里是method你写错了      -->
    <form name="form1" methed ="POST" action="./index.php"/>下面的代码<?phpvar_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>这是输出:
      

  8.   


    我看了一下代码 。。 气死了让你。。 ! 
     
    <!--                            这里是method你写错了      -->
    <form name="form1" methed ="POST" action="./index.php"/>下面的代码<?phpvar_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>这是输出:

    太感谢你了,刚刚另一个读者也给我指出了这个错误,我改了没弄好,后来解决了,本来想给你发消息说解决问题了的,可是这个APP一次最多只能回复三条,我回复不了了,实在太谢谢你们,给你们大佬点赞。谢谢,谢谢!