Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <style>
- .error {color: #FF0000;}
- </style>
- </head>
- <body>
- <?php
- $errors = [];
- $submitted = false;
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["text_in"])) {
- $errors['text_in'] = "Field 'Text' is required";
- } else {
- $text_in = $_POST["text_in"];
- $submitted = true;
- }
- }
- ?>
- <form method="post" action="/">
- Text: <input type="text" name="text_in" value="<?php echo $text_in; ?>">
- <span class="error">* <?php echo $errors['text_in']; ?></span>
- <br>
- <br>
- <input type="submit" name="submit" value="Submit">
- </form>
- <?php
- if ($submitted && count($errors) == 0) {
- echo "<h2>Your Input:</h2>";
- echo $text_in;
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement