I'm new to development. Try to Learning php but I'm Having issue with php form. Here Is my Problem. I have Two Form In a page. So, When I submit data in first form then second form show > > Undefined index. Other hand, When I submit data in second form then first form show > > Undefined index. I'm try to receive data using >>> $_SERVER["PHP_SELF"]
Here Is my Enter Code
<!DOCTYPE html>
<html>
    <head>
        <title> Hello world</title>
        <link rel= "stylesheet" href="style.css" />
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    </head>
    <body class="container mt-5">
        <?php
            $name=$email="";
            if($_SERVER["REQUEST_METHOD"]=="POST"){
                $name = test_input($_POST["name"]);
                $email = test_input($_POST["email"]);
            }
            function test_input($data){
                $data = trim($data);
                $data = stripslashes($data);
                $data = htmlspecialchars($data);
                return $data;
            }
        ?>
        <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" class="row">
            <div class="col-auto">
                <label class="visually-hidden" for="autoSizingInput"> Name</label>
                <input type="text" class="form-control" id="autoZizingInput" name="name" placeholder="User name"></input>
            </div>
            <div class="col-auto">
            <input type="email" class="form-control" id="autoZizingInput" name="email" placeholder="Enter Email"></input> 
           
            </div>
            <div class="col-auto">
            <button type="submit" class="btn btn-primary">Submit</button>
            </div>
            
        </form>
        <div class="container">
            <div class="row mt-5">
               <?php 
                if(!empty($name)&& !empty($email)):?>
                    <h1>Your Name Is <?php echo $name;?> & Email Address <?php echo $email;?></h1>
                    <?php
                endif;
               ?>
            </div>
        </div>
            <?php 
                $color="";
                if($_SERVER["REQUEST_METHOD"]=="POST"):
                  $color = $_POST["color"];
                endif;
            ?>
            <form class="row mt-5" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
                <input type="text" class="form-control" placeholder="Enter colot name" name="color"></input>
                <button type="submit" class="btn btn-danger mt-5"> Submit</button>
            </form>
            <div class="row">
                <?php 
                    if(!empty($color)):?>
                    <h1>Color Is <?php echo $color;?><h1>
                  <?php      
                    endif;
                ?>
            </div>
    </body>
</html>
 
    