我正在从w3school学习php,我正在尝试运行此代码,但是当我单击“提交”按钮而不填写表单时显示错误。这是我的代码,该代码位于名为" form.php "
的文件中<html>
<body>
<style type="text/css">
</style>
<h2>PHP Form Validation Example</h2>
<form method="post" action="welcome.php">
Name: <input type="text" name="name">
<br><br>
E-mail: <input type="text" name="email">
<br><br>
Website: <input type="text" name="website">
<br><br>
Comment: <textarea name="comment" rows="5" cols="40"></textarea>
<br><br>
Gender:
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="male">Male
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
这是我的另一个名为&#34; welcome.php &#34;
的文件<?php
$name = $_POST["name"];
$email = $_POST["email"];
$website = $_POST["website"];
$comment = $_POST["comment"];
$gender = $_POST["gender"];
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $comment;
echo "<br>";
echo $gender;
?>
但是当我提交表格而没有填写表格时,它会显示出来。
注意:未定义的索引:第7行的C:\ xampp \ htdocs \ self \ welcome.php中的性别
请有人帮助找到错误............