Having an issue with php

Hi there, I am currently creating a madlib form in php. I have been having issues with validation and getting my madlib story to print/echo my story when clicking submit. My index.php isnt showing the madlib text field entries typed in by the user. I am running xampp and using Apache and MySQL , so I know that my browser is refreshing to the current project I am working on when i type in the brower “local host”/“folder name”/".php file"… Its kinda hard to explain.

I need the submit button to process and validate all text fields, and to show my madlibs story with all blanks filled. I also need the validation to deny any numbers typed into the text fields. I just dont know what I am doing wrong. I feel super close to solving this but I have been at it almost 5 hours now. Im loosing it lol!

Here is the code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>

        .error
        {
            color:#FF0001;
        }

    </style>
</head>

<body>

<?php

    //Define variables to empty values
    $name= $soundEff= $bandNa= $musicLab= $noun= "";

    $nameErr= $soundErr= $bandErr= $musicErr= $nounErr = "";


    //input fields validation
    if($_SERVER["REQUEST_METHOD"] == "POST"){


        //String validation for song name
        if(empty($_POST["name"])){
            $nameErr = "*Please enter in a song name*";
        }else{
            $name = $_POST["name"];
            //check if song name contains only letters and whitespace
            if(!preg_match("'/^[A-Za-z]*$/'",$name)){
                $nameErr = "Only alpahbets and white space are allowed";
            }
        }
    
        //String validation for sound effect
        if(empty($_POST["sound"])){
            $soundErr = "*Please enter in a song name*";
        }else{
            $soundEff = $_POST["sound"];
            //check if sound contains only letters and whitespace
                if(!preg_match("'/^[A-Za-z]*$/'",$soundEff)){
                    $soundErr = "*Only alpahbets and white space are allowed*";
                }
            }

        //String validation for band name
        if(empty($_POST["band"])){
            $bandErr = "*Please enter in a song name*";
        }else{
            $bandNa = $_POST["band"];
            //check if band name contains only letters and whitespace
                if(!preg_match("'/^[A-Za-z]*$/'",$bandNa)){
                    $bandErr = "*Only alpahbets and white space are allowed*";
                }
            }

        //String validation for music label
        if(empty($_POST["music"])){
            $musicErr = "*Please enter in a song name*";
        }else{
            $musicLab = $_POST["music"];
            //check if music label name contains only letters and whitespace
            if(!preg_match("'/^[A-Za-z]*$/'",$musicLab)){
                $musicErr = "*Only alpahbets and white space are allowed*";
                }
            }

        //String validation for noun
        if(empty($_POST["noun"])){
            $nounErr = "*Please enter in a song name*";
        }else{
            $noun = $_POST["noun"];
            //check if noun contains only letters and whitespace
                if(!preg_match("'/^[A-Za-z]*$/'",$noun)){
                    $nounErr = "*Only alpahbets and white space are allowed*";
                    }
            }
    

        function input_data($data){
            $data = trim($data);
            $data = stripslashes($data);
            $data = htmlspeacialchars($data);
            return $data;
        }
    }
    
?>

    

        <h2>Madlibs Form</h2>
        <span class="error">*required field</span>
        <br><br>

        <!--Start of form-->
        <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">

        <!--song name textfield-->
        Please make up a song name and enter it here:

        <input type = "text" name="name">
        <span class="error">*<?php echo $nameErr; ?> </span>
        <br><br>

         <!--sound textfield-->
         Please describe a sound and enter it here (i.e. boom, snap, crack, hiss, etc..):

        <input type = "text" name="sound">
        <span class="error">*<?php echo $soundErr; ?> </span>
        <br><br>

         <!--band name textfield-->
         Please make up a band name and enter it here:

        <input type = "text" name="band">
        <span class="error">*<?php echo $bandErr; ?> </span>
        <br><br>

         <!--music label name textfield-->
         Please make up a music label name and enter it here:

        <input type = "text" name="music">
        <span class="error">*<?php echo $musicErr; ?> </span>
        <br><br>

         <!--noun textfield-->
       
         Please describe a noun (person, place, or thing) and enter it here:

        <input type = "text" name="noun">
        <span class="error">*<?php echo $nounErr; ?> </span>
        <br><br>

        <input type="submit" name="submit" >
        <br><br>   

</form>

<?php

if(isset($_POST['submit'])){
    if($nameErr == "" && $soundErr == "" && $bandErr == "" &&  $musicErr == "" && $nounErr == ""){
        echo"<p class='madlib'>I know a song called <b><font color='yellow'>$name</font></b> that uses a <b><font color='yellow'>$noun</font></b> for its lead singer.</p>";

        echo"<p class='madlib'>The song is by a band called <b><font color='yellow'>$bandNa</font></b>.</p>";
        
        echo"<p class='madlib'>This song makes a <b><font color='yellow'>$soundEff</font></b> sound when it plays through a speaker.</p>";

        echo "<p class='madlib'>When music producers hear this song, they will have to sign this band to a label called <b><font color='yellow'>$musicLab</font></b>.</p>";

        echo "<p class='madlib'>Fin.</p>";
    }else{
        echo "<h3><font color='red'>*You did not fill the form out correctly*</font></h3>";
    }
}

?>


    

   
</body>
</html>

Hi @gabora94. What is the error message you are getting?