首页 > Linux操作系统 > Linux操作系统 > PHP表单处理指南


原创 Linux操作系统 作者:jieforest 时间:2012-06-14 09:36:43 0 删除 编辑
One of the key things to learn if you are just starting to learn PHP is how to handle forms. This process seems to stump new developers to PHP but this shouldn’t be a big obstacle.

PHP has many features that allow for simple data gathering and easy form. processing. In this tutorial, I will discuss how to use the action method of the form. and show you how to create a simple form. that you can use on your site that will allow your visitors to contact you via email.

This will require the creation of two items: the HTML form. and the PHP script. that will handle it. The tutorial includes a snippet of PHP and HTML source code that you can use as a starter for your form.

Setting up the HTML

Here is my simple HTML contact form.:





When you look at this HTML contact form. you may notice that most HTML form. elements have a name, id and value. The id attribute is not required but if you are doing any JavaScript. or have CSS styles you may need to use them. The name property is what we will use to get the values in PHP.

There are two ways to send form. data, GET and POST. For the purposes of this article, I will be sending this data via POST, as you can see in the
tag. If you would like to learn more about the differences between GET and POST, please see our article detailing the difference at length.

Our PHP script. will be named “handler.php” and it is given in the action portion of the tag. You can name your PHP script. whatever you like, as long as you place it here so the form. knows what to do when the user hits submit.

来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录


  • 博文量
  • 访问量