dsgm5631 2017-05-03 08:59
浏览 394

不能POST php

I have a really simple php form to learn php. I have the code from a tutorial. My html is:

<form action="php/learnphp.php" method="post">
    <table border="0">
        <tr>
            <td>Name</td>
            <td align="center">
                <input type="text" name="username" size="30" />
            </td>
        </tr>

        <tr>
            <td>Address</td>
            <td align="center">
                <input type="text" name="streetaddress" size="30" />
            </td>
        </tr>

        <tr>
            <td>City</td>
            <td align="center">
                <input type="text" name="cityaddress" size="30" />
            </td>
        </tr>

        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="Submit" />
            </td>
        </tr>

    </table>
</form>

my php file is:

<?php

        $usersName = $_POST['username'];
        $streetAddress = $_POST['streetaddress'];
        $cityAddress = $_POST['cityaddress'];

        echo '<p>Your Information</p>';

        // You can combine variables with text using a .

        echo $usersName. ' lives at </br>';
        echo $streetAddress. ' in </br>';
        echo $cityAddress. '</br></br>';       ?>

If I press the submit button i get an error that says: Cannot POST /php/learnphp.php.

i have the form in the root map and my php in a map called 'php'. I know it's probably really simple but i cant seem to figure it out.

  • 写回答

2条回答 默认 最新

  • dtxq82489 2017-05-03 10:47
    关注

    can you please try this.It's work for me.

    my.php

    <form action="learnphp.php" method="post">
        <table border="0">
            <tr>
                <td>Name</td>
                <td align="center">
                    <input type="text" name="username" size="30" />
                </td>
            </tr>
    
            <tr>
                <td>Address</td>
                <td align="center">
                    <input type="text" name="streetaddress" size="30" />
                </td>
            </tr>
    
            <tr>
                <td>City</td>
                <td align="center">
                    <input type="text" name="cityaddress" size="30" />
                </td>
            </tr>
    
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" value="Submit" name="submit" />
                </td>
            </tr>
       </table>
    </form>
    

    learnphp.php

    <?php
    if(isset($_POST["submit"]))
    {
        $usersName = $_POST['username'];
        $streetAddress = $_POST['streetaddress'];
        $cityAddress = $_POST['cityaddress'];
    
        echo '<p>Your Information</p>';
    
            // You can combine variables with text using a .
    
            echo $usersName. ' lives at </br>';
            echo $streetAddress. ' in </br>';
            echo $cityAddress. '</br></br>';     
    }
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题