第三课 设计WEB前端页面 (二)
2016-03-22 21:05
507 查看
学习目标:熟悉PHP语法规则、编码方法和HTML页面简单设计
1.用户名和密码的验证。(1)当没有输入密码、用户名,提示用户名和密码不能为空。
(2)当输入后,提示你输入的密码和用户名是什么。
提示以上两个功能:
Post:隐藏式,的所有人看不到具体信息。
Get:开放式,所有人都看到。
多数情况下使用post,比较安全。
编码如下:
<html> <head> <title>用户名和密码验证</title> </head> <body> <form id="form1" name="form1" method="post"> <tr> <td height="35" align="center" class="STYLE1">用户名 <input name="user" type="text" size="16"/> </td> </tr> <tr> <td height="35" align="center" class="STYLE1">密码 <input name="password" type="password" size="16"/> </td> </tr> <tr> <td height="35" align="center"><input type="submit" name="Submit" value="登陆"/></td> </tr> </form> <?php if(isset($_POST['Submit'])) { $user=$_POST['user']; $password=$_POST['password']; if(empty($user)||empty($password)) { echo "<script>alert('用户名和密码不能为空');window.location.href='UserPass.php';</script>"; }else{ echo "输入的用户名为:$user,输入的密码为:$password<br/>"; } } ?> </body> </html>
效果图:
在上一个文件的基础上又添加了一些菜单项,代码如下:
<html> <head> <title>用户名和密码验证</title> </head> <body> <form id="form1" name="form1" method="post"> <br> <td height="35" align="center" class="STYLE1">用户名: <input name="user" type="text" size="16"/> </td> </br> <br> <td height="35" align="center" class="STYLE1">密码: <input name="password" type="password" size="16"/> </td> </br> <br> <td height="35" align="center" class="STYLE1">性别: <select name="sex"> <option>女</option> <option>男</option> </select> </td> </br> <br> <td height="35" align="center" class="STYLE1">邮箱: <input name="email" type="text" size="36"/> </td> </br> <br> <td height="35" align="center" class="STYLE1">手机: <input name="phone" type="text" size="12"/> </td> </br> <br> <td height="35" align="center" class="STYLE1">地址: <input name="adr" type="text" size="45"/> </td> </br> <br> <td height="35" align="center"><input type="submit" name="Submit" value="登陆"/></td> </br> </form> <?php if(isset($_POST['Submit'])) { $user=$_POST['user']; $password=$_POST['password']; $sex=$_POST['sex']; $email=$_POST['email']; $phone=$_POST['phone']; $adr=$_POST['adr']; if(empty($user)||empty($password)||empty($sex)||empty($email)||empty($phone)||empty($adr)) { echo "<script>alert('用户名和密码不能为空');window.location.href='UserPass.php';</script>"; }else{ echo "你的用户名为:$user,<br/>"; echo "你的密码为:$password,<br/>"; echo "你的性别为:$sex,<br/>"; echo "你的邮箱为:$email,<br/>"; echo "你的手机为:$phone,<br/>"; echo "你的地址为:$adr,<br/>"; } } ?> </body> </html>
以上代码,是本人上课时总结的。如有问题,请及时告诉博主,谢谢!
相关文章推荐
- 【深入浅出jQuery】源码浅析--整体架构(转)
- 【自学笔记】 css 如何改变光标,及各种光标
- NodeJS + PhantomJS 抓取页面信息以及截图
- placeholder的样式设置
- ssh+extjs4 用户、角色、权限模块的实现
- JSON规范
- 快速搭建 Node.js 开发环境以及加速 npm
- javascript 对象
- js url传值中文乱码之解决之道
- 我所理解的JS执行环境和作用域链
- Html+CSS hack技术介绍 以及常用hack
- jQuery学习 day01
- JSon实体类快速生成插件 GsonFormat
- advanced JavaScript Skills ——Require.js(一)
- 这些web前端特效你造吗?
- 每日一bootstrap 下拉菜单
- 剑指offer:数组中重复的数字
- Java开发之String与StringBuffer
- jQuery transform类型实例方法探究
- javascript学习2