Laravel is a powerful php software framework and it's super easy to learn. Now I'm going to teach you that how to create a html form using laravel pattern. It's super simple and easy! So, keep reading my article for learn this. Here is a simple core php form using laravel pattern. First I'm going to create a dummy html form in the index.php file.
Above that form's, I used two input fields like username and password field. And finally one submit button.
Now it's time to create PHP function. So, I'm going to create new php file like my_form.php
and create functions...
First I create form_open() function and pass two parameters $action and $method. Action means which url will be loaded after click the login button and the method is which method
data will pass from browser to server like POST, GET etc.
and return html form opening tag!
After that function, I'm going to create html form closing tag like below...
function form_open($action, $method)
Finally I create input tag function and pass three values. 1st is mention for input type operator, 2nd is input name and 3rd is input value.
function form_input($type, $name, $value = null)
Now adding above three methods in one file(my_form.php).
And include this my_form.php file into index.php file using php require_once method!
Now it's time to replace form opening tag to form_open method with parameters. First value is null, because same page will be loaded after submit the login button. And second value is post, because I want to pass data from browser to server by post method.
Now replace input type tag to form_input method with parameters. 1st one is input type
which is text, password, submit etc. 2nd one is field name and 3rd one is field value(It's optional).
And finally replace form close tag to form_close method.
Al-Amin Sarker is a Bangladesh times best Web Engineer. He helps to build web based software. He studied at Computer Science and Engineering in Rajshahi University, Rajshahi, Bangladesh. He has more than 6 years of experience on building robust and scalable web applications (not websites) with cutting edge technologies Continue reading...