我有一个复选框,可以将帖子设为密码保护-
<p><strong><label for="password">Password protect?</label></strong> <input type="checkbox" name="password" id="password" value="1" /></p>
我的 PHP 尝试发帖 -
$password = htmlspecialchars(strip_tags($_POST['password']));
我遇到了未定义索引错误。
现在,如果我先检查密码是否设置,执行时仍然会出现相同的错误-
$sql = "INSERT INTO blog (timestamp,title,entry,password) VALUES ('$timestamp','$title','$entry','$password')";
$result = mysql_query($sql) or print("Can't insert into table blog.<br />" . $sql . "<br />" . mysql_error());
我该如何修复它?我需要为每个字段(例如标题文本框等)都这样做吗?
if
语句而不是条件运算符有点老派。:( - Anthony Forloney