I keep getting the following message when loading the form:
Notice:  Undefined index: name in C:\xampp\htdocs\main.php on line 267
Notice:  Undefined index: email in C:\xampp\htdocs\main.php on line 275
Notice:  Undefined index: message in C:\xampp\htdocs\main.php on line 281
I've looked and followed a number of examples to fix this issue but for some reason I can't seem to find the solution. Any ideas?
<?php
if (isset($_POST["submit"])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $human = intval($_POST['human']);
    $from = 'enquiry'; 
    $to = 'dgdrd@live.com'; 
    $subject = 'Message from Visitor';
    $body = "From: $name\n E-Mail: $email\n Message:\n $message";
    // Check if name has been entered
    if (!$_POST['name']) {
        $errName = 'Please enter your name';
    }
    // Check if email has been entered and is valid
    if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        $errEmail = 'Please enter a valid email address';
    }
    //Check if message has been entered
    if (!$_POST['message']) {
        $errMessage = 'Please enter your message';
    }
    // If there are no errors, send the email
    if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
        if (mail ($to, $subject, $body, $from)) {
            $result='<div class="alert alert-success">We will get in tocuh soon.</div>';
        } else {
            $result='<div class="alert alert-danger">Error! Try again later.</div>';
        }
    }
}
?>
<form class="form-horizontal" role="form" method="post" action="main.php">
    <div class="form-group">
        <label for="name">name</label>
        <input type="text" id="name" name ="name" class="form-control" placeholder="" value="<?php echo htmlspecialchars($_POST['name']); ?>">
                <?php $errName=''; echo "<p class='text-danger'>$errName</p>";?>
    </div>
    <div class="form-group">
        <label for="email1">email</label>
        <input type="email" id="email" name ="email" class="form-control" aria-describedby="emailHelp" placeholder="" value="<?php echo htmlspecialchars($_POST['email']); ?>">
                <?php $errEmail=''; echo "<p class='text-danger'>$errEmail</p>";?>
    </div>
    <div class="form-group">
        <label for="message">comment</label>
        <textarea class="form-control" rows="6" name="message"><?php echo htmlspecialchars($_POST['message']);?></textarea>
                <?php $errMessage=''; echo "<p class='text-danger'>$errMessage</p>";?>
    </div>
    <button type="submit" name="submit" id="submit" class="btn btn-primary btn-wrapper">Send</button>
    <hr>
    <div class="form-group">
        <div class="col-sm-12">
            <?php $result=''; echo $result; ?>  
        </div>
    </div>
</form>
 
     
    