Form data print on the same page after submitting

 <html>

    <head>
        <title>Form Page</title>
    </head>
    <body>
        <form action="<?php echo $_SERVER["PHP_SELF"] ?>", method="post">
            Name: <input type="text" name="fname"><br><br>
            Age: <input type="text" name="age"><br><br>
            <input type="submit" name="save">
        </form>

        <?php
        if(isset($_POST["save"])) {
            echo $_POST["fname"] . "<br>";
            echo $_POST["age"] . "<br>";
        }
        ?>

    </body>
</html>



Comments

Popular posts from this blog

Ajax Insert Records in Database Tutorial in PHP

SubQuery with EXISTS and NOT EXISTS in PHP

Submitting HTML Form data in JSON File (without MySql Database) in PHP