Note: Undefined index
I have a checkbox that can make a password password protected -
<p><strong><label for="password">Password protect?</label></strong> <input type="checkbox" name="password" id="password" value="1" /></p>
My php is trying to post
$password = htmlspecialchars(strip_tags($_POST['password']));
I get an undefined index error.
Now, if I first try to check if a password has been set, I get the same error -
$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());
How to fix it? Do I have to do this for every field, such as a header text field and that's it?