[請益] 變數未定義問題?
<?php
require("connect.php");
$guestName=$_POST["guestName"];
$guestEmail=$_POST["guestEmail"];
$guestGender=$_POST["guestGender"];
$guestSubject=$_POST["guestSubject"];
$guestContent=$_POST["guestContent"];
$guestTime = date("Y:m:d H:i:s",time()+28800);
if(isset($guestName)){
mysqli_query($link,"insert into guest
value('','$guestName','$guestEmail','$guestGender','$guestSubject','$guestTime','$guestContent','','')");
header("location:p13-show.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"" rel="nofollow">https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="" rel="nofollow">https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我要留言</title>
<link rel="stylesheet"
href="" rel="nofollow">https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>
<style>
 .container{
  margin:auto;
  background-color:#f5f5f5;
  width:800px;
  padding-bottom: 20px;
 }
 .button{
  text-align:center;
  padding:20px 0;
 }
 .top h3{
  font-family:微軟正黑體;
  text-align:center;
  padding:10px 0;
 }
 .form-group{
  font-family:微軟正黑體;
  font-size:16px;
 }
</style>
<body>
<div class="container">
 <div class="top">
    <h3>新增留言</h3>
    </div>
    <form id="form1" name="form1" method="post" action=""
class="form-horizontal">
        <div class="form-group">
            <label for="guestName" class="col-sm-4 control-label">暱稱:
</label>
            <div class="col-sm-6">
                <input type="text" class="form-control" placeholder="您的暱稱
" name="guestName" id="guestName" />
            </div>
        </div>
        <div class="form-group">
            <label for="guestEmail" class="col-sm-4 control-label">信箱:
</label>
            <div class="col-sm-6">
                <input type="text" class="form-control" placeholder="您的信箱
" name="guestEmail" id="guestEmail" />
            </div>
        </div>
        <div class="form-group">
            <label for="guestGender" class="col-sm-4 control-label">性別:
</label>
            <label class="radio-inline">
                <input type="radio" name="guestGender" id="radio" value="男"
/> 男
            </label>
            <label class="radio-inline">
                <input type="radio" name="guestGender" id="radio2" value="女"
/>女
            </label>
        </div>
        <div class="form-group">
            <label for="guestSubject" class="col-sm-4 control-label">留言主旨
:</label>
            <div class="col-sm-6">
              <input type="text" class="form-control" name="guestSubject"
id="guestSubject" />
            </div>
        </div>
        <div class="form-group">
          <label for="guestContent" class="col-sm-4 control-label">留言內容:
</label>
          <div class="col-sm-6">
              <textarea name="guestContent" class="form-control"
id="guestContent" rows="5"></textarea>
          </div>
        </div>
        <div class="button">
            <input type="submit" name="button" id="button" value="送出"
class="btn"/>
        </div>
    </form>
</div>
</body>
</html>
請問各位高手,不好意思我不懂怎麼貼到網路上,所以只好貼在板上,排版很醜請見諒
我在寫一個留言板,但連上留言版都會顯示Warning: Undefined array key "guestName" in C:\xampp\htdocs\hello.php on line
4
Warning: Undefined array key "guestEmail" in C:\xampp\htdocs\hello.php on
line 5
Warning: Undefined array key "guestGender" in C:\xampp\htdocs\hello.php on
line 6
Warning: Undefined array key "guestSubject" in C:\xampp\htdocs\hello.php on
line 7
Warning: Undefined array key "guestContent" in C:\xampp\htdocs\hello.php on
line 8
請問一下,php的變數不是不用宣告嗎?還是問題是出在Html身上,請指教一下
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 218.164.209.141 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1636438285.A.74E.html
推
11/09 14:37, 
                                4年前
                            , 1F
11/09 14:37, 1F
→
11/09 16:47, 
                                4年前
                            , 2F
11/09 16:47, 2F
→
11/10 11:55, 
                                4年前
                            , 3F
11/10 11:55, 3F
→
11/10 14:38, 
                                4年前
                            , 4F
11/10 14:38, 4F
→
11/11 13:50, 
                                4年前
                            , 5F
11/11 13:50, 5F
→
11/11 13:51, 
                                4年前
                            , 6F
11/11 13:51, 6F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章
                            39
                        
                            80