我试图使用$_GET方法来获取用户在表单中键入的任何内容,然后在if语句中使用它.它产生了一个错误


Im trying to use the $_GET method to obtain whatever the user has typed in a form and then using it in an if statement. It has come up with an error

这是我的HTML页面在网站上的代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>index</title>
</head>
<body>
<html>
<body>
<form action="Untitled-4.php" method="get">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html> 
</body>
</html>

,这是我的"Untitled-4.php"文件的代码:

<html>
<body>

<?php 
if ($_GET["name"] == "tom"){
echo "hello you are special";
}
?>
</body>
</html> 

这是我得到的错误:

" PHP文件第7行未定义的索引"

我试图使用GET方法来获取"name"框中要在if语句中使用的任何用户类型,如果用户在"tom"中键入"您是特殊的"。谁能告诉我这是什么问题?

(问题堆栈溢出说的是一个可能的重复是一个完全不同的问题)

检查是否先设置了变量:

<html>
<body>

<?php 
if (isset($_GET["name"])) {
if ($_GET["name"] == "tom"){
    echo "hello you are special";}
} else {
    echo "you are not special";
}
?>
</body>
</html> 

由于某种原因,我只是再次尝试了它,没有更改我的代码,它似乎是工作的,我实际上没有做任何事情