聯絡表格上工作,我發現了XAMPP返回我以下錯誤:未定義指數:發佈
公告:未定義的索引:在/Applications/XAMPP/xamppfiles/htdocs/demo/demo2.php發送上線18
注意:未定義的變量:CSS在/Applications/XAMPP/xamppfiles/htdocs/demo/demo2.php在線39
在這個代碼:
<?php
session_name("fancyform");
session_start();
$_SESSION['n1'] = rand(1,20);
$_SESSION['n2'] = rand(1,20);
$_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2'];
$str='';
if(isset($_SESSION['errStr'])){
$str='<div class="error">'.$_SESSION['errStr'].'</div>';
unset($_SESSION['errStr']);
}
$success='';
if($_SESSION['sent'])
{
$success='<h1>Thank you!</h1>';
$css='<style type="text/css">#contact-form{display:none;}</style>';
unset($_SESSION['sent']);
}
?>
但在另外公頃第二,其還坡平標籤內部錯誤(像這樣的):
說明:未定義指數:交在/Applications/XAMPP/xamppfiles/htdocs/demo/demo2.php上線
第68行是以下內容,似乎錯誤在value=""
附近,但只要我不是PHP大師,任何人都知道如何解決以下錯誤?
線68例如:
<input type="text" class="validate[required,custom[onlyLetter]] form-control" name="name" required id="name" value="<?=$_SESSION['post']['name']?>" />
意味着$ _SESSION ['sent']沒有在這個頁面或從你到達當前頁面的頁面中定義 –
也許你的意思是使用'$ _POST'而不是?那麼你應該使用'if(isset($ _ POST ['sent']))''。另外,如果'$ _SESSION'是你需要的,你應該使用'isset()'。 – jeroen