How to post HTML form that calls the same page with PHP

1 Answer

0 votes
<!DOCTYPE html>
<html>
    <head>
        <title>Post HTML Form</title>
    </head>
    <body>
        <div>
            <?php
            if ( ! empty( $_POST['user_name'] ) ) {
                print "Your name is: ".$_POST['user_name'];
            }
            ?>
            <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
                <p>
                    What is your name: <input type="text" name="user_name" />
                </p>
            </form>
        </div>
    </body>
</html>

<!--

run

Your name is: Fox

-->

 



answered Nov 20, 2018 by avibootz

Related questions

...