Skip to content

Instantly share code, notes, and snippets.

@ti-ka
Created April 11, 2015 00:21
Show Gist options
  • Save ti-ka/64b6156bffff622e6c57 to your computer and use it in GitHub Desktop.
Save ti-ka/64b6156bffff622e6c57 to your computer and use it in GitHub Desktop.
Check if a variable is posted and show value
<?php
$items = array("name", "email","age"); //Assuming these fields
foreach($items as $item){
$val = (isset($_POST[$item])) ? $_POST[$item] : "";
//You might want to prevent MySQL injections by real_escape or use PDO prepare for safety.
echo "<input type='text' name='$item' value='$val' />";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment