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

 更新时间:2016年03月21日 15:25:45   作者:可笑痴狂  
这篇文章主要介绍了使用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="image/school_1.jpg" height="50%" width="60%">
    <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="mysql_stu.php" method="post" name="reg_stu">
    <table align="center" cellspacing="0" bordercolor="#FFFFFF" width="60%" bordercolorlight="#FFFFFF" border="1" cellpadding="3">
      <tr bgcolor="#CCCCCC">
        <td width="100%" align="center" valign="bottom" height="19" colspan="2">
        <font face="隶书" size="4" color="#000000">请仔细填写以下内容</font></td>
      </tr>
      <tr>
        <td width="30%" align="right" height="19" >姓名:</td>
        <td width="70%"><input type="text" name="reg_name" size="10" maxlength="18" ></td>
      </tr>
      <tr>
        <td width="30%" align="right" height="19">性别:</td>
        <td width="70%"><input type="radio" name="reg_sex" value="男" checked >男<input type="radio" name="sex" value="女">女</td>
      </tr>
      <tr>
        <td width="30%" align="right" height="19">年龄:</td>
        <td width="70%"><input type="text" name="reg_age" size="5" maxlength="15"></td>
      </tr>
      <tr>
        <td width="30%" align="right" height="19">班级:</td>
        <td width="70%"><input type="text" name="reg_class" size="20"></td>
      </tr>
      <tr>
        <td width="30%" align="right" height="19">身份证号:</td>
        <td width="70%"><input type="text" name="reg_id" size="20"></td>
      </tr>
      <tr>
        <td width="30%" align="right" height="19">联系电话:</td>
        <td width="70%"><input type="text" name="reg_tele" size="20"></td>
      </tr>
      <tr>
        <td width="30%" align="right" height="19">电子邮件:</td>
        <td width="70%"><input type="text" name="reg_email" size="20"></td>
      </tr>
      <tr>
        <td width="100%" align="center" colspan="2"><input type="submit" value="马上注册">
        <input type="reset" value="全部重写"></td>
      </tr>
    </table>
    </form>
    <marquee behavior="scroll">
    <center><img src="image/school2.jpg" height="15%" width="15%">
    <img src="image/lake.jpg" height="15%" width="15%">
    <img src="image/flower.jpg" height="15%" width="15%">
    <img src="image/autumn.jpg"height="16%" width="16%">
    <img src="image/bridge.jpg" height="15%" width="15%">
    <img src="image/beauty.jpeg" height="15%" width="15%">  
    <img src="image/party1.jpeg" height="18%" width="17%">
    <img src="image/party2.jpeg" height="18%" width="18%">
    <img src="image/party3.jpeg" height="18%" width="17%">
    <img src="image/party4.jpeg" height="18%" width="17%">
    </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="register.php">注册</a></font>
  <p><center><font color="red" size="6"><b>信息查询登录</b></font></center></p>
    <form action="stu_info.php" method="post" name="log_stu">
    <table align="center" cellspacing="0" bordercolor="#FFFFFF" width="60%" bordercolorlight="#FFFFFF" border="1" cellpadding="3">
      <tr bgcolor="#CCCCCF">
        <td width="100%" align="center" valign="bottom" height="19" colspan="2">
        <font face="隶书" size="4" color="#000000">请输入姓名和身份证号</font></td>
      </tr>
      <tr>
        <td width="50%" align="right" height="19" >请输入姓名:</td>
        <td width="70%"><input type="text" name="log_name" size="20"></td>
      </tr>
      <tr>
        <td width="30%" align="right" height="19">请输入身份证号:</td>
        <td width="70%"><input type="text" name="log_id" size="20"></td>
      <tr>
        <td width="100%" align="center" 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" height="200" bgcolor="#FFFFCC" width="60%">
    请各位同学先到各个学院完善注册信息,<br>做好报道注册工作,<br>同时按要求完善电子档案信息。
    <br><br>希望广大同学尽快适应新环境,<br>认识新朋友,尽快投入到学习工作当中!<br><br>教务处电话:12345678<br>保卫科电话:87654321</marquee></p></font>
    </center>
</body>
</html>

2016321152226105.jpg (1281×703)

(3)、查询信息显示模块(stu_info.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/bg6.jpg">
  <?php
    if($_POST['log_name']=='')
    {
      echo "<center><font color='blue' size='8'><b>姓名不能为空!请重新输入!<br></b></font></center>";
      echo "<center><font size='6'><a href='mysql_stu.php'>重新登录</font></center>";
    }
    else
    { 
      $link = mysql_connect('localhost','root','Dongsheng');
      if(!$link)
      {
        echo "与数据库连接失败!";
        die('Could not connect: ' .mysql_error());
      }
      $result=mysql_select_db(mis_stu)
        or die('选择mis_stu数据库失败:'.mysql_error());
      mysql_query("set names gb2312");
      $slt=mysql_query("select * from stu_reg");
      $arr=mysql_fetch_assoc($slt);
      $flag=0;
      while($arr)
      {
        if($_POST['log_name']==$arr['stu_name'])
        {
          $flag=1;
          if($_POST['log_id']==$arr['stu_id'])
          {
            echo "<font color='red' size='8'><b>登录成功,您的基本信息为:<br></b></font></center><br>";
            echo "<font size='6'>姓名:".$arr['stu_name']."<br>";
            echo "<font size='6'>性别:".$arr['stu_sex']."<br>";
            echo "<font size='6'>年龄:".$arr['stu_age']."<br>";
            echo "<font size='6'>班级:".$arr['stu_class']."<br>";
            echo "<font size='6'>身份证号:".$arr['stu_id']."<br>";
            echo "<font size='6'>联系电话:".$arr['stu_tele']."<br>";
            echo "<font size='6'>电子邮件:".$arr['stu_email']."<br>";
            break;
          }
          else
          {
            echo "<center><font color='blue' size='8'><b>密码错误!请<a href='mysql_stu.php'>重新输入。<br></b></font></center>";
            break;
          }
        }
        $arr=mysql_fetch_assoc($slt);
      }
      if($flag==0)
        echo "<center><font color='blue' size='8'><b>对不起!您查询的用户不存在,请先返回<a href='register.php'>注册</a><br></b></font></center>";
      mysql_close($link);
      echo "<center><font color='blue' size='6'><a href='mysql_stu.php'>切换用户</a><br></b></font></center>";
    }
     
  ?>
</body>
</html>

2016321152251020.jpg (1281×703)

相关文章

  • php遍历目录与文件夹的多种方法详解

    php遍历目录与文件夹的多种方法详解

    介绍几个php遍历目录的方法,可以遍历目录及目录中的文件,供大家参考
    2013-11-11
  • PHP二进制与字符串之间的相互转换教程

    PHP二进制与字符串之间的相互转换教程

    欢迎大家在这里学习PHP二进制与字符串之间的相互转换!问题也肯定是很多朋友在关心的,想要了解的朋友可以看一下。
    2016-10-10
  • PHP编写RESTful接口的方法

    PHP编写RESTful接口的方法

    这篇文章主要为大家详细介绍了PHP编写RESTful接口的方法,如何使用PHP编写RESTful接口,感兴趣的小伙伴们可以参考一下
    2016-02-02
  • PHP rsa加密解密使用方法

    PHP rsa加密解密使用方法

    这篇文章主要介绍了PHP rsa加密解密使用方法,本文讲解了生成公钥、私钥及PHP中使用生成的公钥、私钥进行加密解密实例,需要的朋友可以参考下
    2015-04-04
  • laravel框架与其他框架的详细对比

    laravel框架与其他框架的详细对比

    今天小编就为大家分享一篇laravel框架与其他框架的详细对比,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-10-10
  • 一个自定义位数的php多用户计数器代码

    一个自定义位数的php多用户计数器代码

    一个自定义位数的php多用户计数器代码...
    2007-03-03
  • php时间戳转换的示例

    php时间戳转换的示例

    PHP获取“今天的时间戳”,再通过“今天”获取昨天和明天0点和23:59:59的时间戳
    2014-03-03
  • Yii2下session跨域名共存的解决方案

    Yii2下session跨域名共存的解决方案

    这篇文章主要介绍了Yii2下session跨域名共存的解决方案,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-02-02
  • PHP函数引用返回的实例详解

    PHP函数引用返回的实例详解

    其实PHP函数引用与php中变量引用一样,都使用的是&符号了,那么今天我们就一起来看看函数的引用返回的一些例子,有需要的朋友们可以参考借鉴,下面来一起看看吧。
    2016-09-09
  • Redis在Laravel项目中的应用实例详解

    Redis在Laravel项目中的应用实例详解

    这篇文章主要给大家介绍了关于Redis在Laravel项目中应用的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用laravel具有一定的参考学习价值,需要的朋友们下面跟着小编来一起学习学习吧。
    2017-08-08

最新评论