我现在正在制作联系表格,但出现以下错误。未定义变量:check.php 中的 name_result
我想让网站像:欢迎先生(女士)的名字
HTML(更新)↓
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Contact form</h1>
<form method="POST" action="check.php">
<div>
<div>
<label for="" class="font">Title:</label>
<label for="" class="font">Name:</label>
</div>
<div>
<div>
<input type="radio" name="gender" value="Mr.">
<input type="radio" name="gender" value="Ms.">
<input type="text" name="name" value="" class="text"><br>
</div>
<br>
<div>
<input type="submit" value="submit" name="submit">
</div>
</form>
</body>
</html>
check.php(更新)↓
<?php
$gender = $_POST['gender'];
$name = $_POST['name'];
$name_result = '';
if(isset($_POST['submit'])){
if(isset($_POST['gender'])){
$name_result = 'welcome ' . $gender . $name;
}else{
$name_result = 'Oops! No name typed';
}
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>confirm</h1>
<div>
<p><?php echo $name_result; ?></p>
</div>
</body>
</html>
先感谢您。
幕布斯6054654
呼唤远方
函数式编程