应用系统定制开发连接数据库,connet.php:
- <meta charset="utf-8">
- <?php
- $conn=mysqli_connect("localhost","root","123456","ly")or die("应用系统定制开发连接数据库服务器失败!".mysqli_error());
- mysqli_query($conn,"set names utf8");
- ?>
登录页面Login.php:
- <html>
- <head>
- <title>登录</title>
- <meta charset="UTF-8">
- <link rel="stylesheet" type="text/css" href="./css/index1.css">
- <style>
- body{height:100%;}
- </style>
- </head>
- <body style="background: url(./images/1.png);">
- <div class="index_01">
- <table style="width: 100%;height:100%;" >
- <tr>
- <td align="center" >
- <table align="center" width=350 height=230; class="index_table" >
- <form method ="POST" action = "doloading.php" name="frmLogin">
- <tr align="center" style="font-size:25px;">
- <td colspan="2" style="font-size:35px;">用户登录</td>
- </tr>
- <tr>
- <td align="center" style="font-size:25px;">用户名</td>
- <td><input type="name" maxlength="16" name="uid" placeholder="应用系统定制开发请输入账号" style="width:180px;font-size:20px;border-radius: 8px; "></td>
- </tr>
- <tr>
- <td align="center" style="font-size:25px;">密 码</td>
- <td><input name="password" type="password" maxlength="16" placeholder="应用系统定制开发请输入密码" style="width:180px;font-size:20px;border-radius: 8px; "></td>
- </tr>
- <tr align="center">
- <td colspan="2">
- <input type="submit" name="denglu" value="登录" class="btn">
- <input type="reset" name="rs" value="重置" class="btn">
-
- </td>
- </tr>
- </form>
- </table>
- </td>
- </tr>
- </table>
- </div>
- </body>
- </html>
登录处理,doloading.php
- <meta charset="utf-8">
- <?php
- session_start();
- $uid=$_POST['uid'];
- $pwd=$_POST['password'];
- if($uid==""||$pwd=="")
- {
- echo "<script>alert('用户名或密码为空,请重新登录');location='Login.php';</script>";
- }else{
- include_once("connet.php");
- $sql="select * from user where uid='$uid' and upwd='$pwd' ";
- $result=mysqli_query($conn,$sql);
- $num=mysqli_num_rows($result);
- if($num!=0){
- echo "<script>alert('登录成功');location='show.php';</script>";
- $_SESSION['user']['islogin']=true;
- }else
- {
- echo "<script>alert('登录失败');location='Login.php';</script>";
- }
-
-
-
- }
- ?>
注册页面,regist.php
- <html>
- <head>
- <title>注册</title>
- <meta charset="UTF-8">
- <link rel="stylesheet" type="text/css" href="./css/index1.css">
- <style>
- body{height:100%;}
- </style>
- </head>
- <body style="background: url(./images/1.png)">
- <div class="index_01" >
- <table style="width: 100%;height:100%;" >
- <tr>
- <td align="center" >
- <form action="doregister.php " name="dl" method="post">
- <table align="center" width=350 height=230; style="font-family:宋体;font-size:25px;">
- <tr align="center">
- <td colspan="2" style="font-size:35px;">注册用户</td>
- </tr>
- <tr>
- <td align="center">用户名</td>
- <td>
- <input type="name" maxlength="20" name="id" placeholder="手机号/邮箱" style="width:180px;font-size:20px;border-radius: 8px; ">
- </td>
- </tr>
- <tr>
- <td align="center">密 码</td>
- <td >
- <input name="password" type="password" maxlength="16" placeholder="请输入密码" style="width:180px;font-size:20px;border-radius: 8px; ">
- </td>
- </tr>
- <tr>
- <td align="center">再次输入密码</td>
- <td>
- <input name="confirmPassword" type="password" maxlength="16" placeholder="请再次输入密码" style="width:180px;font-size:20px;border-radius: 8px; ">
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <input type="submit" name="zu" value="注册" style="font-size:17px;border-radius:12px;" class="btn"/>
- <input type="reset" name="zu" value="重置" style="font-size:17px;border-radius: 12px;" class="btn">
-
- </td>
- </tr>
- </table>
- </form>
- </td>
- </tr>
- </table>
- </div>
- </body>
- <html>
注册处理,doregist.php,往数据库添加数据
- <meta charset="utf-8">
- <?php
- $uid=$_POST['id'];
- $pwd=$_POST['password'];
- $confpwd=$_POST['confirmPassword'];
- //判断密码是否一致
- if($pwd!=$confpwd)
- {
- echo "<script>alert('密码不匹配,请重新输入');location='register.php';</script>";
- }
- //连接数据库进行查询
- include_once("connet.php");
- $sql1="select * from user ";
- $res=mysqli_query($conn,$sql1);
- //判断账户密码是否为空
- if($uid!=null&&$pwd!=null)
- {
- while($myrow=mysqli_fetch_object($res))
- {
- //判断账户是否与数据库中已有的账户一致
- if($uid!=$myrow->uid){
- $sql2="insert into user values('".$uid."','".$pwd."')";
- $res1=mysqli_query($conn,$sql2);
- if($res1){
- echo "<script>alert('注册成功');location='Login.php';</script>";
- }
- }else{
- echo "<script>alert('注册失败,该账号已被注册');location='register.php';</script>";
- }
- }
- }else{
- echo "<script>alert('注册失败,请输入账号和密码');location='register.php';</script>";
- }
- ?>
主页面,show.php:
- <?php
- header('Content-type: text/html; charset=UTF8');
- ?>
- <html>
- <head>
- <title>我的留言板.查看留言</title>
- <link rel="stylesheet" type="text/css" href="./css/index1.css">
- <link rel="stylesheet" type="text/css" href="./css/index2.css">
- </head>
- <body background="./images/7.jpg" style="background-size:cover;background-attachment: fixed;" >
-
-
- <center>
- <h2>我的留言板</h2>
- <input type = "button" value = "添加留言" onclick="location.href='authority.php'" class="button"/>
- <input type = "button" value = "查看留言" onclick="location.href='select.php'" class="button"/>
- <input type = "button" value = "登 录" onclick="location.href='Login.php';" class="button"/>
- <input type = "button" value = "注 册" onclick="location.href='register.php';" class="button"/>
- <hr width = "70%">
- </center>
- <?php
- include_once("connet.php");
- mysqli_query($conn,'set names utf8');
- $str = "select * from tbliuyan";
- $result = mysqli_query($conn,$str);
- while($myrow = mysqli_fetch_row($result)){
- ?>
- <div style="color:blue;border: 1px solid black;width: 700px;margin: 0 auto;height: 100px;">
- <div style="width: 80px;float: left;" ><img src="http://q1.qlogo.cn/g?b=qq&nk=<?php echo $myrow[4];?>&s=640" style="width: 80px;height: 80px;margin-top: 10px;">
- </div>
- <div style="width: 620px;margin-left: 120px;margin-top:15px;color: black;" >
- <span style="margin-top:60px;">名称:<?php echo $myrow[1];?></span><br>
- <span>ID:<?php echo $myrow[0];?></span><br>
- <span>标题:<?php echo $myrow[2];?></span><br>
- <span>内容:<?php echo $myrow[3];?></span>
- </div>
- </div>
-
-
- <?php
- }
- ?>
- <span class="STYLE2"style="margin-left: 1100px;"><?php
- $rows = mysqli_num_rows($result);
- echo "查询结果为:".$rows.'条记录';
- ?><a href="add.php">:继续添加</a></span>
-
-
-
-
- </body>
- </html>
添加一个权限,authority.php:
- <meta charset="utf-8">
- <?php
- session_start();
- if (isset($_SESSION['user']['islogin'])&&$_SESSION['user']['islogin']==true) {
- echo"<script>alert('欢迎访问该页面'); location='add.php';</script>";
- }else{
- echo"<script>alert('对不起,您无权访问,返回首页');location='show.php';</script>";
- }
添加页面,add.php
- <?php
- header('Content-type: text/html; charset=UTF8');
- ?>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="./css/index1.css">
- <title>我的留言板.添加留言</title>
- </head>
- <body background="./images/7.jpg" style="background-size:cover;" >
- <center>
- <h2>我的留言板</h2>
- <input type = "button" value = "修改留言" onclick="location.href='update.php'" class="button"/>
- <input type = "button" value = "删除留言" onclick="location.href='del.php'" class="button"/>
- <input type = "button" value = "退出登录" onclick="location.href='logout.php'" class="button"/>
- <hr width = "70%">
- </center>
- <div class="k1">
- <form action = "doAdd.php" method = "post">
- <h1>添加留言
- </h1>
- <label>
- <span>用户名称:</span>
- <input type="text" name="author" />
- </label>
- <label>
- <span>主题:</span>
- <input type="text" name="title"/>
- </label>
- <label>
- <span>内容 :</span>
- <textarea name="content"></textarea>
- </label>
- <label>
- <span>QQ:</span>
- <input type="text" name="qq"/>
- </label>
- <div style="margin-left:125px">
- <input type="submit" value="提交留言" class="submit">
- <input type = "reset" value = "重置" class="reset">
- </div>
- </div>
- </form>
- </body>
- </html>
添加处理,doAdd.php:
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>添加留言</title>
- </head>
- <body>
- <?php
- session_start();
- include_once("connet.php");
- if (isset($_POST['author'],$_POST['title'],$_POST['content'],$_POST['qq'])) {
- if ( !($_POST['author']&&$_POST['title']&&$_POST['content']&&$_POST['qq'])) {
- echo "输入数据不允许为空,单击<a href='javascript:onclick=history.go(-1)'>这里</a>返回";
- }else{
- $str="insert into tbliuyan values(NULL,'".$_POST['author']."','".$_POST['title']."','".$_POST['content']."','".$_POST['qq']."')";
- $result=mysqli_query($conn, $str);
- if($result){
- echo "留言添加添加成功,点击<a href='show.php'>查看</a>";
- }else{
- echo "<script>alert('添加失败');history.go(-1);</script>";
- }
- }
- }else{
- echo "<script>alert('添加失败');history.go(-1);</script>";
- }
- ?>
- </body>
- </html>
更新页面。update.php:
- <?php
- header('Content-type: text/html; charset=UTF8');
- ?>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="./css/index1.css">
- <title>我的留言板.添加留言</title>
- </head>
- <body background="./images/7.jpg" style="background-size:cover;" >
- <center>
- <h2>我的留言板</h2>
- <input type = "button" value = "查看留言" onclick="location.href='show.php'" class="button"/>
- <input type = "button" value = "退出登陆" onclick="location.href='index.php'" class="button"/>
- <hr width = "70%">
- </center>
- <div class="k1">
- <form action = "doupdate.php" method = "post">
- <h1>更改信息
- <span>根据qq号更改信息</span>
- </h1>
- <label>
- <span>用户名称:</span>
- <input type="text" name="author" />
- </label>
- <label>
- <span>主题:</span>
- <input type="text" name="title" />
- </label>
- <label>
- <span>内容 :</span>
- <textarea name="content" ></textarea>
- </label>
- <label>
- <span>ID:</span>
- <input type="text" name="tid" />
- </label>
- <div style="margin-left:125px">
- <input type="submit" value="修改留言" class="submit">
- <input type = "reset" value = "重置" class="reset">
- </div>
- </div>
- </form>
- </body>
- </html>
更新处理,doupdate.php:
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>修改留言</title>
- </head>
- <body>
- <?php
- include_once("connet.php");
- if (!($_POST['author']&&$_POST['title']&&$_POST['content']&&$_POST['tid'])) {
- echo "输入数据不允许为空,单击<a href='javascript:onclick=history.go(-1)'>这里</a>返回";
- }else{
-
- $str="update tbliuyan set username='".$_POST['author']."',title='".$_POST['title']."',message='".$_POST['content']."' where id=".$_POST['tid'];
- $result=mysqli_query($conn, $str);
- if($result){
- echo "留言更新添加成功,点击<a href='show.php'>查看</a>";
- }else{
- echo "<script>alert('更新失败');history.go(-1);</script>";
- }
- }
- ?>
- </body>
- </html>
删除页面,del.php
- <?php
- header('Content-type: text/html; charset=UTF8');
- ?>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="./css/index1.css">
- <title>我的留言板.查询留言</title>
- </head>
- <body background="./images/7.jpg" style="background-size:cover;" >
- <center>
- <h2>我的留言板</h2>
- <input type = "button" value = "修改留言" onclick="location.href='update.php'" class="button"/>
- <input type = "button" value = "查看留言" onclick="location.href='show.php'" class="button"/>
- <input type = "button" value = "退出登录" onclick="location.href='index.php'" class="button"/>
- <hr width = "70%">
- </center>
- <div class="k1">
- <form action = "dodel.php" method = "post">
- <h1>删除留言
- <span>根据ID删除留言</span>
- </h1>
- <label>
- <span>ID:</span>
- <input type="text" name="id"/>
- </label>
- <div style="margin-left:125px">
- <input type="submit" value="删除留言" class="submit">
- <input type = "reset" value = "重置" class="reset">
- </div>
- </form>
-
- </div>
- </body>
- </html>
删除处理,dodel.php:
- <meta charset="utf-8">
- <?php
- include_once("connet.php");
- $id = $_POST['id'];
- if(isset($_POST['id']))
- {
- if($_POST['id'])
- {
- $sql="delete from tbliuyan where id ='".$_POST['id']."' ";
- $res=mysqli_query($conn,$sql);
- if($res){
- echo "<script>alert('删除成功,返回首页');location='show.php';</script>";
- }
- else{
- echo "<script>alert('删除失败');location='show.php'</script>";
- }
- }
- else
- {
- echo "<script>alert('数据为空,不能允许删除');location='del.php';</script>";
- }
- }
- ?>
查找页面.select.php:
- <?php
- header('Content-type: text/html; charset=UTF8');
- ?>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="./css/index1.css">
- <title>我的留言板.查询留言</title>
- </head>
- <body background="./images/7.jpg" style="background-size:cover;" >
- <center>
- <h2>我的留言板</h2>
- <input type = "button" value = "返回首页" onclick="location.href='show.php'" class="button"/>
- <input type = "button" value = "退出登录" onclick="location.href='logout.php'" class="button"/>
- <hr width = "70%">
- </center>
- <div class="k1">
- <form action = "doselect.php" method = "post">
- <h1>查看留言
- <span>根据qq号查看留言</span>
- </h1>
- <label>
- <span>QQ:</span>
- <input type="text" name="qq"/>
- </label>
- <div style="margin-left:125px">
- <input type="submit" value="查看留言" class="submit">
- <input type = "reset" value = "重置" class="reset">
- </div>
- </form>
-
- </div>
- </body>
- </html>
查找处理,doselect.php:
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <?php
- if (isset($_POST['qq'])) {
- include_once("connet.php");
- mysqli_query($conn,'set names utf8');
- $str = "select * from tbliuyan where qq=".$_POST['qq'];
- $result = mysqli_query($conn,$str);
- while($myrow = mysqli_fetch_row($result)){
- ?>
- <div style="color:blue;border: 1px solid black;width: 700px;margin: 0 auto;height: 100px;">
- <div style="width: 80px;float: left;" ><img src="http://q1.qlogo.cn/g?b=qq&nk=<?php echo $myrow[4];?>&s=640" style="width: 80px;height: 80px;margin-top: 10px;">
- </div>
- <div style="width: 620px;margin-left: 120px;margin-top:15px;color: black;" >
- <span style="margin- top:60px;">名称:<?php echo $myrow[1];?></span><br>
- <span>ID:<?php echo $myrow[0];?></span><br>
- <span>标题:<?php echo $myrow[2];?></span><br>
- <span>内容:<?php echo $myrow[3];?></span>
- </div>
- </div>
- <?php
- }
- }
- ?>
- </body>
- </html>
创建注销登录,logout.php:
- <meta charset="utf-8">
- <?php
- session_start();
- $_SESSION=array();
- setcookie(session_name(),null,time()-1,'/');
- echo"<script>alert('退出成功');location='show.php';</script>";
- session_destroy();