1<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
2//there is no reason to use this to submit form data to the same page
3<form action="">
4//will do the same thing
1<?php if (!empty($_POST)): ?>
2 Welcome, <?php echo htmlspecialchars($_POST["name"]); ?>!<br>
3 Your email is <?php echo htmlspecialchars($_POST["email"]); ?>.<br>
4<?php else: ?>
5 <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
6 Name: <input type="text" name="name"><br>
7 Email: <input type="text" name="email"><br>
8 <input type="submit">
9 </form>
10<?php endif; ?>
11