Jump to content

Deku219

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Deku219

  1. all have the same errors: UNDEFINED VARIABLE....

    HOW CAN I FIX IT??????

    <!DOCTYPE html>
    
    <?php
        define ("TITLE", "GET &amp; POST");
        
        if($_SERVER["REQUEST_METHOD"] == "POST"){
           $name = $email = "";
           $nameError= $emailError = "";
            
            if(!isset($_POST["post_name"])){
                $nameError = "Please Enter Your Name.";
               
            } else {
                $name = inputInfo($_POST["post_name"]); 
            }
            
            if(!isset($_POST["post_email"])){
                $emailError = "Please Enter Your Email.";
            } else {
                $email = inputInfo($_POST["post_email"]);
            }
        }
    
        function inputInfo($data){
            $data = trim(stripslashes(htmlspecialchars($data)));
            return $data;
        }
    ?>
    
    <html>
        <head>
            <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE-Edge">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <title>PHP => Loops</title>
            <link href="css/bootstrap.min.css" rel="stylesheet">
        </head>
        
        <body>
            <div class="container">
                <h1><?php echo TITLE?></h1>
                
                <h4>Submitted to current page</h4>
                <p class="text-danger">* Required Field</p>
                <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
                <!-- this line -->    <small class="text-danger">* <?php echo $nameError ?></small>
                    <input type="text" placeholder="Name" name="post_name" class="form-control col-sm-6 offset-3" value="<?php echo $name; ?>"><br>
                  <!-- this line -->   <small class="text-danger">* <?php echo $emailError; ?></small>
                    <input type="email" placeholder="Email" name="post_email"  class="form-control col-sm-6 offset-3" value="<?php echo $email; ?>"><br>
                    <input type="submit" value="submit" name="post_submit" class="btn btn-success offset-8">
                </form>
          
                <?php
                    echo "<h4>Your Info:</h4>";
                <!-- this line --> echo "$name <br> $email <br>";
                ?>
                
            </div>
            
            <script src="js/jquery.min.js"></script>
            <script src="js/bootstrap.bundle.min.js"></script>
        </body>
    </html>

    Thanks !

×
×
  • Create New...