![](/img/trans.png)
[英]PHP - Self form submission: $_SERVER['PHP_SELF'] OR action=“”?
[英]<form action=“<?=$_SERVER['PHP_SELF']?>” method=“post”>
我不明白為什么在下面的代碼中,從不執行else子句。 將顯示該表單,但是當我按下Submit按鈕時,什么也沒有發生。 有人可以幫忙嗎? 干杯。
<!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'])) {
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.