How To Pass Parameters In Form Action In HTML
Last Updated : Jan 1, 2023
IN - HTML
In this tutorial we will show you the solution of how to pass parameters in form action in HTML, first here as this article belongs to php, so user must have basic knowledge of php language and php tags, etc.
Today, our topic is how to pass parameters in form action in html.
Here, we want to describe you that how you are able to pass the parameters from one page to another or same page with values assigned to parameters. Let us understand how this can be done.
Step By Step Guide On How To Pass Parameters In Form Action In HTML :-
Now, here we will provide you the html code, in which we create a form.
Whereas php is also used in this, you have to first connect it to server and have to create table, means your database must be prepared.
In some next steps we help you to understand what is going to done in this code.
<!Doctype html> <html> <head> <title> display data from database </title> </head> <body> <form method="get" action="demo.php?id=1"> <p><input type="text" name="name" placeholder="Enter name" /></p> <p><input type="password" name="password" placeholder="Enter password" /></p> <input type="submit" name="data_send" value="Submit " /> </form> </body> </html>
- First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
- Secondly, the <html> tag is used to indicate the beginning of an HTML document.
- As above now <head> tag is used to contain information about web page.
- In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
- Here we create a body tag, which is a paired tag. All the data which we want to show on webpage is written here. And in this case we create a form tag.
- And the method used is get, you can also use post. Now, after this we create input tags with label tags. The label tags are used to show you text on the web screen.
- Whereas the input tag is used to make a field for input. And here it is mandatory to give name to input tag.
- In form action, you have to give the link of webpage where you want user to redirect when submit button gets clicked.
- Here we use ? after action this is because to make a concatenation link between html page and database.
- Here, you have to specify the name of columns of table. In which you want to enter the values that we feed in input tag. And also known as parameter.
- At last, the <body> and <html> tags are closed with </body> and </html> respectively.
In conclusion, here we can say that you have to link the parameters with the help of action of form and through the input tag.
Rest work is done with the help of database and concatenate database with html. I hope this tutorial on how to pass parameters in form action in HTML helps you.