Advertisement
Guest User

imagick form submit

a guest
Feb 8th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3.     <head>
  4.         <style>
  5.             .error {color: #FF0000;}
  6.         </style>
  7.     </head>
  8.     <body>
  9.  
  10.         <?php
  11.         $errors = [];
  12.         $submitted = false;
  13.        
  14.         if ($_SERVER["REQUEST_METHOD"] == "POST") {
  15.             if (empty($_POST["text_in"])) {
  16.                 $errors['text_in'] = "Field 'Text' is required";
  17.             } else {
  18.                 $text_in = $_POST["text_in"];
  19.                 $submitted = true;
  20.             }            
  21.            
  22.         }
  23.  
  24.         ?>
  25.                
  26.                        
  27.         <form method="post" action="/">
  28.             Text: <input type="text" name="text_in" value="<?php echo $text_in; ?>">
  29.             <span class="error">* <?php echo $errors['text_in']; ?></span>
  30.             <br>
  31.             <br>
  32.             <input type="submit" name="submit" value="Submit">
  33.         </form>
  34.  
  35.         <?php
  36.         if ($submitted && count($errors) == 0) {
  37.             echo "<h2>Your Input:</h2>";
  38.             echo $text_in;        
  39.         }        
  40.         ?>
  41.  
  42.     </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement