the code I'm gonna post below is meant to to display the data that the user inputs from a previous page (their name, email and phone number), using the POST method. However, the name, for some reason, is not posting and i get 2 errors because of this.
Error 1: Notice: Undefined variable: error in -insert-parth-here/details.php on line X
Error 2: Notice: Undefined index: name in -insert-parth-here/details.php on line Y
I have annotated the lines X and Y below. I have no idea why I'm getting the error for the name and not for the email and phone number even though technically they are the same.
<?php   
    if(isset($_POST) && !empty($_POST))
    {
        if(isset($_POST['name']) && !empty($_POST['name']))
        {
            $_SESSION['user']['name'] = $_POST['name'];
            $name = $_POST['name'];
        }
        else
        {
            $error .= "Please enter your Name"; //LINE Y
        }
        if(isset($_POST['email']) && !empty($_POST['email']))
        {
            $_SESSION['user']['email'] = $_POST['email'];
            $name = $_POST['email'];
        }
        else
        {
            $error .= "Please enter your email";
        }
        if(isset($_POST['phone']) && !empty($_POST['phone']))
        {
            $_SESSION['user']['phone'] = $_POST['phone'];
            $name = $_POST['phone'];
        }
        else
        {
            $error .= "Please enter your phone";
        }
    }
    echo "<h3> Name : " ; echo $_SESSION['user']['name']; echo "</h3>"; // LINE X
    echo "<h3> Email : " ; echo $_SESSION['user']['email']; echo "</h3>";
    echo "<h3> Phone : " ; echo $_SESSION['user']['phone']; echo "</h3>";
?>  
 
     
    