【发布时间】:2017-05-03 08:59:39
【问题描述】:
我有一个非常简单的 php 表单来学习 php。我有教程中的代码。我的html是:
<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>
我的 php 文件是:
<?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>'; ?>
如果我按下提交按钮,我会收到一条错误消息:Cannot POST /php/learnphp.php。
我在根地图中有表格,而我的 php 在名为“php”的地图中。我知道这可能很简单,但我似乎无法弄清楚。
【问题讨论】:
-
learnphp.php和html相关文件不一样?
-
是的,有2个文件:第一个是带有表单的html,第二个是learnphp.php
-
learnphp.php 在文件夹 php 中吗?你能分享两个文件的位置吗
-
它们在同一个文件夹中吗?
-
验证你的html表单中的action属性路径是否正确。