第三课 设计WEB前端页面 (二)
来源:互联网 发布:oppo手机4g网络不稳定 编辑:程序博客网 时间:2024/05/29 02:47
学习目标:熟悉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>
以上代码,是本人上课时总结的。如有问题,请及时告诉博主,谢谢!
0 0
- 第三课 设计WEB前端页面 (二)
- web前端之CSS设计指南二:页面布局(固定宽度、流动、弹性)
- web 前端 (二)
- 设计前端(二)
- Web 前端本地化(二)
- 浅谈WEB页面提速(前端向)
- web前端页面优化
- web 前端 切页面
- web前端工程师修炼之道——第三章 web设计基本概念
- Web前端开发规范(二)
- Web前端开发规范(二)
- web前端 基础部分(二) CSS
- Web前端持续集成方案(二)
- web前端基本用法(二)
- web前端开发笔记(二)
- web前端面试题(二)
- WEB前端资源集(二)
- web前端面试题汇总(二)
- android日常2016-3-22 页面跳转、内容传递和返回
- matlab基本知识点
- 利用dmesg和addr2line来重现bug
- 笔试题
- S5PV210 UART编程流程 协议类模块操作
- 第三课 设计WEB前端页面 (二)
- Activity_Class_Fragments
- 2015 年度新增开源软件排名 TOP 100
- swing
- 扩展欧几里得算法
- BZOJ 1197: [HNOI2006]花仙子的魔法
- Java中对象的内存分配问题
- 自定义模板引擎_1
- leetcode198.[DP]House Robber