php简单表单运用
首先建立一个login.htm文件,下面是里面的代码
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<media charset = "utf-8"/>
<title>登录</title>
</head>
<body>
<form name = "login" action = "easyForm.php" method = "POST">
<input type = "text" name = "username" placeholder ="请输入用户名"/>
<input type = "password" name = "password" placeholder ="请输入密码"/>
<input type ="radio" name = "sex" value =1>男
<input type ="radio" name = "sex" value =0>女
<input type = "submit" name = "sub" value ="开始登陆"/>
</form>
</body>
</html>
然后建立一个 easyForm.php 文件,内容如下
//三种获取方式
var_dump($_GET);
var_dump($_POST);
var_dump($_REQUEST);
var_dump($_POST['username']) //单独获取某个信息
//$_GET变量接受所有以get方式发送的请求,及浏览器地址栏中的?之后的内容
//$_POST变量接受所有以post方式发送的请求,例如,一个form以method=post提交
//提交后php会处理post过来的全部变量
//而$_REQUEST支持两种方式发送过来的请求,即post和get它都可以接受
//显示不显示要看传递方法,get会显示在url中(有字符数限制),post不会在url中显示
//可以传递任意多的数据(只要服务器支持)
?>