Your problem is on this line:
$initial = mysql_real_escape_string($_POST['initial']);
Basically, the issue is caused whenever the POST variable initial
does not exist. When the POST variable initial
does not exist, the index initial
will not exist in the $_POST array.
You should always check to see if a POST or GET variable exists before you attempt to use it. You can do this by using the function isset:
if(isset($_POST['initial'])){
//initial exists as a POST variable
} else{
//initial does not exist as a POST variable
}
Of course, you could also use this in ternary form:
$initial = isset($_POST['initial']) ? mysql_real_escape_string($_POST['initial']) : false;
if($initial !== false){
//Good to go
}
Some causes of POST variables not existing when you think they should:
- Form element names not matching up with the POST variables that you're trying to access. Ex: Your field is called
name
but you're trying to access the POST variable names
.
- A user accessing the page directly, instead of accessing it via a form.