PHP:POST未定义的索引错误[重复]

I know there are similar questions asked but none of them are helping in my case.

I have a form written as such:

    <div class = "Contact">
        <form action="formprocessor.php" method="post">
            <label>Name: </label>
            <input name="name" type="text" size="25" />

            <label>Course: </label>
            <input name="course" type="text" size="25" />

            <label>Book: </label>
            <input name="book" type="text" size="255" />

            <label>Price: </label>
            <input name="price" type="text" size="7" />

            <label>Email: </label>
            <input name="email" type="text" size="255" />

            <label>Phone #: </label>
            <input name="phone" type="text" size="12" />

            <input name="mySubmit" type="submit" value="Submit!" />
        </form>
    </div>

and relevant PHP code from formprocessor.php:

<?php
$name = $_POST["name"];
$course = $_POST["course"];
$book = $_POST["book"];
$price = $_POST["price"];
$email = $_POST["email"];
$phone = $_POST["phone"];

echo $name;
?>

Clicking the sumbit button on the form gives me these errors:

Notice: Undefined index: name in /Users/Jose/PhpstormProjects/334 Final Project/formprocessor.php on line 3

Notice: Undefined index: course in /Users/Jose/PhpstormProjects/334 Final Project/formprocessor.php on line 4

Notice: Undefined index: book in /Users/Jose/PhpstormProjects/334 Final Project/formprocessor.php on line 5

Notice: Undefined index: price in /Users/Jose/PhpstormProjects/334 Final Project/formprocessor.php on line 6

Notice: Undefined index: email in /Users/Jose/PhpstormProjects/334 Final Project/formprocessor.php on line 7

Notice: Undefined index: phone in /Users/Jose/PhpstormProjects/334 Final Project/formprocessor.php on line 8

Any help is appreciated. Thanks in advance

</div>
<?php
if(isset($_POST['mySubmit']))
{
    $name = $_POST["name"];
    $course = $_POST["course"];
    $book = $_POST["book"];
    $price = $_POST["price"];
    $email = $_POST["email"];
    $phone = $_POST["phone"];

    echo $name;
}
?>
<?php
$name   = isset($_POST["name"]) ? $_POST["name"] : '';
$course = isset($_POST["course"]) ? $_POST["course"] : '';
$book   = isset($_POST["book"]) ? $_POST["book"] : '';
$price  = isset($_POST["price"]) ? $_POST["price"] : '';
$email  = isset($_POST["email"]) ? $_POST["email"] : '';
$phone  = isset($_POST["phone"]) ? $_POST["phone"] : '';

echo $name;
?>