Store form inputs easily

Published 25 Nov by SuperNOVA

Store form inputs easilyWhen we deal with large forms we have to use multiple assignment operations for the $_POST/$_GET variables. For forms with large input fields this becomes very tedious. However, there is a neat trick you can use to avoid this problem.
Lets say there is an HTML form like the following: Now, in action.php we can use the following piece of code to accomplish our task. What we have done here is that we have used array_keys to extract all the keys of the $_POST array and then created a variable with the value submitted using POST. Consider the line – $$value=$_POST[$value]; Now, if the $_POST[‘username’]=”admin”; then the above line would yield: $username=”admin”; Therefore, simplifying the process we would have gone through. Don’t forget to share!