PHP編寫學校網站上新生註冊登陸程式的執行個體分享_php執行個體

來源:互聯網
上載者:User

就弄了三個頁面:

(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>


(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>

(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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.