PHP编写学校网站上新生注册登陆程序的实例分享

就弄了三个页面:

(1)、新生信息注册模块(register.php):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>班级注册表</title> </head> <body background="image/bg3.jpg"> <center><img src="https://www.jb51.net/image/school_1.jpg"> <marquee behavior="alternate" bgcolor="#FF0000"><b>河南理工大学真诚欢迎2012级新同学到校学习</b></marquee> </center> <p><center><font color="red" size="6"><b><blink>新生注册系统</blink></b></font></center></p> <form action="https://www.jb51.net/mysql_stu.php" method="post"> <table cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" cellpadding="3"> <tr bgcolor="#CCCCCC"> <td valign="bottom" colspan="2"> <font face="隶书" size="4" color="#000000">请仔细填写以下内容</font></td> </tr> <tr> <td >姓名:</td> <td><input type="text" size="10" maxlength="18" ></td> </tr> <tr> <td>性别:</td> <td><input type="radio" value="男" checked >男<input type="radio" value="女">女</td> </tr> <tr> <td>年龄:</td> <td><input type="text" size="5" maxlength="15"></td> </tr> <tr> <td>班级:</td> <td><input type="text" size="20"></td> </tr> <tr> <td>身份证号:</td> <td><input type="text" size="20"></td> </tr> <tr> <td>联系电话:</td> <td><input type="text" size="20"></td> </tr> <tr> <td>电子邮件:</td> <td><input type="text" size="20"></td> </tr> <tr> <td colspan="2"><input type="submit" value="马上注册"> <input type="reset" value="全部重写"></td> </tr> </table> </form> <marquee behavior="scroll"> <center><img src="https://www.jb51.net/image/school2.jpg"> <img src="https://www.jb51.net/image/lake.jpg"> <img src="https://www.jb51.net/image/flower.jpg"> <img src="https://www.jb51.net/image/autumn.jpg"height="16%"> <img src="https://www.jb51.net/image/bridge.jpg"> <img src="https://www.jb51.net/image/beauty.jpeg"> <img src="https://www.jb51.net/image/party1.jpeg"> <img src="https://www.jb51.net/image/party2.jpeg"> <img src="https://www.jb51.net/image/party3.jpeg"> <img src="https://www.jb51.net/image/party4.jpeg"> </center></marquee> </body> </html>

2016321152141216.jpg (1281×703)


(2)、信息查询登录模块(mysql_stu.php):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>新生登陆系统</title> </head> <body background="image/bg1.jpg"> <?php //连接数据库; $link = mysql_connect('localhost','root','Dongsheng'); if(!$link) { echo "与数据库连接失败!"; die('Could not connect: ' .mysql_error()); } $createdb="create database if not exists mis_stu"; $result=mysql_query($createdb) or die("<br>数据库创建失败:".mysql_error()); $result=mysql_select_db(mis_stu) or die('选择mis_stu数据库失败:'.mysql_error()); $createtable="create table if not exists stu_reg (stu_name varchar(30) not null,stu_sex char(2),stu_age int,stu_class varchar(30),stu_id varchar(18),stu_tele varchar(20),stu_email varchar(30))"; $result=mysql_query($createtable) or die('<br>数据表创建失败:'.mysql_error()); //选择数据库 mysql_select_db(mis_stu); if(!empty($_POST['reg_name'])) { $name=$_POST['reg_name']; $sex=$_POST['reg_sex']; $age=$_POST['reg_age']; $class=$_POST['reg_class']; $id=$_POST['reg_id']; $tele=$_POST['reg_tele']; $email=$_POST['reg_email']; //定义插入数据到stu_reg表中的SQL字符串 mysql_query("set names gb2312"); $SQL="insert into stu_reg(stu_name,stu_sex,stu_age,stu_class,stu_id,stu_tele,stu_email) values ('$name','$sex','$age','$class','$id','$tele','$email')"; mysql_query($SQL); mysql_query("COMMIT"); echo "<center><font color='blue' size='10'><b>恭喜您,注册成功!<br>输入以下内容登陆系统查询注册信息</b></font></center>"; } mysql_close($link); ?> <font size='6' color="#FFFF00">登录前请先<a href="https://www.jb51.net/register.php">注册</a></font> <p><center><font color="red" size="6"><b>信息查询登录</b></font></center></p> <form action="stu_info.php" method="post"> <table cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" cellpadding="3"> <tr bgcolor="#CCCCCF"> <td valign="bottom" colspan="2"> <font face="隶书" size="4" color="#000000">请输入姓名和身份证号</font></td> </tr> <tr> <td >请输入姓名:</td> <td><input type="text" size="20"></td> </tr> <tr> <td>请输入身份证号:</td> <td><input type="text" size="20"></td> <tr> <td colspan="2"><input type="submit" value="登录"> <input type="reset" value="清空"></td> </tr> </table> </form>> <center> <p><font face="隶书" size="5" color=red>新生入学需知:<br></font></p> <p><font face="隶书" size="5" color="#0033FF"><marquee behavior="scroll" direction="up" bgcolor="#FFFFCC"> 请各位同学先到各个学院完善注册信息,<br>做好报道注册工作,<br>同时按要求完善电子档案信息。 <br><br>希望广大同学尽快适应新环境,<br>认识新朋友,尽快投入到学习工作当中!<br><br>教务处电话:12345678<br>保卫科电话:87654321</marquee></p></font> </center> </body> </html>

2016321152226105.jpg (1281×703)

(3)、查询信息显示模块(stu_info.php)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6cc6e52eedce7e9efa5a1fc6c56c05a3.html