我正在尝试获取文本框的内容,如果它是某个文本,我希望它显示一条消息。我不断收到错误。
<html>
<head>
<title>Name Tester</title>
</head>
<body>
<h1>Name Tester!</h1><br>
<p>Type your first and last name in the name box and see results!</p>
<p>EX: Name: John Smith</p>
<FORM NAME ="form1" METHOD ="post">
Name: <input type="text" name="firstlastname" value="firstlastname"></input>
<input type="submit" name="submit" value="Submit"></input>
</form>
<?PHP
$firstlastname = $_POST['firstlastname'];
if($firstlastname == "John Smith"){
echo "John Smith is the most used name ever. Just letting you know.";
}
elseif($firstlastname == "First Last"){
echo "That isnt much of a name, whats your REAL name?";
}
?>
</body>
</html>
我得到的错误localhost/index.php
是:
Notice: Undefined index: firstlastname in C:\xampp\htdocs\index.php on line 15
HTML 仍然显示并且 php 仍然有效,但是我收到了这个相当烦人的错误。我想从我的网站上删除。