我不明白为什么在下面的代码中,else 子句从未被执行。表单已显示,但当我按下“提交”按钮时没有任何反应。有人可以帮忙吗?干杯。
<!doctype html>
<html>
<head>
<meta charset = "utf-8">
<title>Listing 12-3</title>
</head>
<body>
<h1>Query the Shop Database</h1>
<h3>Search for a Product</h3>
<p> Use a wildcard if necessary - % in front / behind text</p>
<?php
tryagain:
// Wait for submit
if (!$_POST['submit']) {
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<p> Product Name: <input type ="text" name="product" /></p>
<p><input type="submit" name = "submit" value = "Submit" /></p>
</form>
<?php
}
else {
// Connect to the Shop database
最佳答案
请更改
if (!$_POST['submit']) {
至
if (!isset($_POST['submit'])) {
关于php - <表单操作="<?=$_SERVER[' PHP_SELF']? >"method="帖子">,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32135879/