Created
April 11, 2015 00:21
-
-
Save ti-ka/64b6156bffff622e6c57 to your computer and use it in GitHub Desktop.
Check if a variable is posted and show value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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