Post a form to itself. $PHP_SELF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?php $Fname = $_POST["Fname"]; if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> First Name:<input type="text" maxlength="12" name="Fname" size="12" /> <input type="submit" name="submit" value="submit" /></form> <?php } // if no post else { echo "Hello, "$Fname; } ?> |
and in PHP
1 2 3 |
<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form1"> |