我得到了"未定义索引"的通知,但在我可以看到的url中,字段不是空的。看看自己:
网址:
http://localhost/projektarbeit/version-03/send.php?vorname=asdf&name=asdf&strasse=asdf&hausnr=12&plz=12435&ort=asdf&email=asdf%40gmail.com
注意事项:
Notice: Undefined index: vorname in C:xampphtdocsprojektarbeitversion-03send.php on line 5
Notice: Undefined index: name in C:xampphtdocsprojektarbeitversion-03send.php on line 6
Notice: Undefined index: strasse in C:xampphtdocsprojektarbeitversion-03send.php on line 7
Notice: Undefined index: hausnr in C:xampphtdocsprojektarbeitversion-03send.php on line 8
Notice: Undefined index: plz in C:xampphtdocsprojektarbeitversion-03send.php on line 9
Notice: Undefined index: ort in C:xampphtdocsprojektarbeitversion-03send.php on line 10
Notice: Undefined index: email in C:xampphtdocsprojektarbeitversion-03send.php on line 11
这里有一些代码:
<form action="send.php" action="POST">
<input type="text" name="vorname" pattern="{20}" required>
<input type="text" name="name" pattern="{20}" required>
<input type="text" name="strasse" pattern="{20}" required>
<input type="text" name="hausnr" pattern="[a-zA-Z0-9]+{5}" required>
<input type="text" name="plz" pattern="[0-9]{5}" required>
<input type="text" name="ort" pattern="{20}" required>
<input type="email" name="email" required>
<input type="submit">
</form>
还有我的PHP脚本:
<?php
include 'includes/db-connection.php';
$vorname = $_POST['vorname'];
$name = $_POST['name'];
$strasse = $_POST['strasse'];
$hausnr = $_POST['hausnr'];
$plz = $_POST['plz'];
$ort = $_POST['ort'];
$email = $_POST['email'];
?>
希望有人能帮我:s
进行后期提交的正确方法是使用method
标记,而不是action
标记。
操作包含您的url:send.php和方法:post
<form method="post" action="send.php">
</form>
可能您使用的是Get方法,因为在URL中,查询字符串适用于Get请求。使用表单方法而不是POST操作。