html body formaction=submitform.php3method=GET 姓:inputtype=textname=first_namesize=25maxlength=25 名:inputtype=textname=last_namesize=25maxlength=25 p inputtype=submit /form /body /html 当你输入数据,并按下 submit 按钮后,这个表单将把数据
姓: 名: |
当你输入数据,并按下 submit 按钮后,这个表单将把数据发送到 submitform.php3 。再由这个 PHP 脚本来处理收到的数据,下面就是 submitform.php3 的代码:
mysql_connect(localhost,username,password); mysql_select_db(dbname); mysql_query("INSERTINTOtablename(first_name,last_name) VALUES('$first_name','$last_name') "); print($first_name); print(""); print($last_name); print(" "); |
当你按下 submit 之后,可以看到你输入的名字被显示在一个新的页面中。再看一看浏览器的 URL 栏,它的内容应该是像这样的:
… /submitform.php3?first_name=Fred&last_name=Flintstone |
因为我们用到的是表单 GET 方法,因此数据是通过 URL 来传送到 submitform.php3 的。显然, GET 方法是有局限性的,当要传递的内容很多时,就不能用 GET 了,只能用 POST 方法。但不管用什么方法,当数据传送完成后, PHP 自动的为每一个表单中的字段建立一个和他们的名字(表单的 name 属性)相同的变量。
PHP 变量都已用一个美元符号开头的,这样,在 submitform.php3 脚本处理的过程中,就会有 $first_name 和 $last_name 这两个变量了,变量的内容就是你输入的内容。
我们来检查一下你输入的名字是否真的被输入到数据库中了。启动 MySQL, 在 mysql> 提示符下输入:
mysql> select * from tablename; |
你应该可以得到一个表,内容就是你刚才输入的了:
------------ ------------
| first_name | last_name | ------------ ------------ | 柳 | 如风 ------------ ------------ 1 rows in set (0.00 sec) |
[1] [2] [3]

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment