我有一個允許用戶「創建主題」的頁面,通過驗證過程打開提交此表單,該過程將主題插入數據庫並重新指向返回到主頁面。但是,如果所有字段都未填寫,我希望我的驗證頁面「添加主題」顯示錯誤消息。以下是我的代碼,請您告訴我需要添加此驗證代碼以通知用戶填寫所有內容字段:如何顯示空字段錯誤消息
// get data that sent from form
$topic=$_POST['topic'];
$detail=$_POST['detail'];
$name=$_POST['name'];
$email=$_POST['email'];
$datetime=date("d/m/y h:i:s"); //create date time
$sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";
$result=mysql_query($sql);
if($result){
echo "Successful<BR>";
echo "<a href=main_forum.php>View your topic</a>";
}
else {
echo "ERROR";
}
mysql_close();