Home > Article > Backend Development > What is a php form? How to create a php form (example)
The php form is an area containing form elements. You can create a form by using the ff9c23ada1bcecdd1a0fb5d5a0f18437 tag and inserting relevant form elements into it. Below I will give you a detailed analysis of how to create a form.
Form elements are elements that allow users to enter information in a form (such as text fields, drop-down lists, radio buttons, check boxes, etc.).
Forms are defined using the form tag (ff9c23ada1bcecdd1a0fb5d5a0f18437).
<form action="script.php" method="post"> </form>
As far as PHP is concerned, the most important attribute of the form tag is action, which specifies which page the form data will be sent to. If it is empty, it will be submitted to the page containing the form. That is the current page;
The second attribute is method, which specifies how to send data to the processing page. The two options (get and post) indicate the HTTP method to be used.
method method selection:
##The get method is to pass the submitted data through a series of The (name-value) pair appended to the URL is sent to the receiving page. For example:
http://www.example.com/script.php?name=Homer&gender=M&age=35
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>简单的HTML表单</title> <style type="text/css"> label {font-weight: bold;color: #300ACC;} </style> </head> <body> <form action="demo1.php" method="post"> <fieldset><legend>在下面的表格输入您的信息:</legend> <p><label>姓名: <input type="text" name="name" size="20" maxlength="40" /></label></p> <p><label>邮箱地址: <input type="text" name="email" size="40" maxlength="60" /></label></p> <p><label for="gender">性别: </label><input type="radio" name="gender" value="M" /> 男 <input type="radio" name="gender" value="F" /> 女</p> <p><label>年龄: <select name="age"> <option value="0-29">30岁以下</option> <option value="30-60">30岁 到 60岁 之间</option> <option value="60+">60岁以上</option> </select></label></p> <p><label>评论: <textarea name="comments" rows="3" cols="40"></textarea></label></p> </fieldset> <p align="center"><input type="submit" name="submit" value="提交信息" /></p> </form> </body> </html>Such a form is ready. The final rendering is as follows: Related recommendations:
What is a PHP form and form creation
The above is the detailed content of What is a php form? How to create a php form (example). For more information, please follow other related articles on the PHP Chinese website!