Hey everybody I want to let you know that I have undertaken the grueling task of getting the heck away from WordPress. I was so sick of the problems and updates I had to do all the time. I am now using my ezbloo system and I am integrating all my old posts into the new system. It sucks, but in the end, I will save bundles of time. I needed to keep things simple and that is why I created ezbloo. I'll have more on this later for you guys after I am done with the total integration of my old posts here. So if you are looking for a post and need it faster, shoot me an email and I will make it a priority. [email protected]

Have you ever wanted to put a form in a php function? You can do it and it is fast and easy. You can use this function anywhere on your website. 


Steps to Creating a form in a PHP Funtion

First create 2 files, index.php and functions.php. These files will work together to get the job done.

Functions.php File

In your functions.php file put in the code example beow for this exercise.
<?php

function form(){
echo '
<form method="post" action="">
<input type="text"name="firstName"/>
<input type="submit" name="submit" value="submit"/>
</form>

';
}

?>

Index.php File

In your index.php file put the following lines of code. Make sure that your functions.php file and your index.php file are in the same folder.
<?php if(isset($_POST['submit'])){ echo 'The Name Entered is'.$_POST['firstName']; } include('functions.php'); form(); ?>
Congratulations, you have now learned how to put a form in a php function. Feel free to comment below.