I am trying to follow a PHP contact form tutorial from here! Seems pretty simple and I'm completely new to PHP. However, when running my project, I get so many "Notice" messages and errors!
I managed to fix many of them, by surrounding most variables in issets
if(isset($_POST['name'])){ $name = $_POST['name'];}
if(isset($_POST['email'])){$email = $_POST['email'];}
if(isset($_POST['phone'])){$phone = $_POST['phone'];}
if(isset($_POST['message'])){$message = $_POST['message'];}
if(isset($_POST['human'])){$human = intval($_POST['human']);}
if(isset($_POST['from'])){$from = 'Página Web';}
if(isset($_POST['to'])){$to = 'bla@bla.com';}
if(isset($_POST['name'])){$subject = 'Mensaje de Página Web';}
if(isset($_POST['name'])){$body = "De: $name\n Teléfono: $phone\n E-Mail: $email\n Mensaje:\n $message";}
However, I still get these pesky notifications:
Line 16 is:
if ($_POST["submit"]) {
And the rest are for example found in lines like this:
<div class="col-sm-10">
<textarea class="form-control" rows="4" name="message"><?php echo htmlspecialchars($_POST['message']);?></textarea>
<?php echo "<p class='text-danger'>$errMessage</p>";?>
</div>
even though these variables are declared on the top.
How can I fix the top notice and the "undeclared variable" errors? I've tried looking up other tutorials, but they seem to do the same, ignoring the issets (and making my Netbeans upset and full of warnings!) and using the same syntax.
Help is greatly appreciated.