第七十五天上课 php注册登入审核和文件上传
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第七十五天上课 php注册登入审核和文件上传相关的知识,希望对你有一定的参考价值。
文件上传
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>文件上传</title> <?php if(!(empty($_FILES[‘file‘]) || empty($_POST[‘submit‘]))) { $urls="./my-img/".$_FILES[‘file‘][‘name‘]; //创建文件储存路径 $urls=iconv(‘UTF-8‘,‘gb2312‘,$urls); //处理文件名称乱码 if(file_exists($urls)) //判断文件是否存在 { echo"该文件已经存在"; } else { //上传图片的方法(临时路径,储存路径) move_uploaded_file($_FILES[‘file‘][‘tmp_name‘],$urls); } } ?> <form action="" method="post" enctype="multipart/form-data"> <input type="file" name="file"/> <input type="submit" name="submit" value="上传"/> </form>
(账户管理)注册界面 ZhuCe.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>注册界面</title> <?php if(!empty($_POST[‘ZhuCe‘])) { if(empty($_POST[‘ZhangHao‘])||empty($_POST[‘MiMa‘])||empty($_POST[‘XingMing‘])||empty($_POST[‘ShengRi‘])) { echo"<script> alert(‘请将信息填写完整‘) </script>"; } else { $ZhangHao=$_POST[‘ZhangHao‘]; $MiMa=$_POST[‘MiMa‘]; $XingMing=$_POST[‘XingMing‘]; $XingBie=$_POST[‘XingBie‘]; $ShengRi=$_POST[‘ShengRi‘]; $ZhuangTai="未激活"; $ShiJian=date("Y-m-d H:i:s",time()); include"class/uniondatabase-class.php"; $db=new unionDatabase(); $sql="insert into YongHu values(‘$ZhangHao‘,‘$MiMa‘,‘$XingMing‘,‘$XingBie‘,‘$ShengRi‘,‘$ZhuangTai‘,‘$ShiJian‘)"; $result=$db->query($sql); if($result) { echo "<script>alert(‘注册成功‘)</script>"; } else { echo "<script>alert(‘注册失败‘)</script>"; } } } ?> <form action="" method="post"> <h1 align="center">注册界面</h1><br> <div>输入账号 <input class=‘input‘ type="text" name="ZhangHao"/></div><br> <div>输入密码 <input class=‘input‘ type="password" name="MiMa"/></div><br> <div>确认密码 <input class=‘input‘ type="password"/></div><br> <div>输入姓名 <input class=‘input‘ type="text" name="XingMing"/></div><br> <div>选择性别 <input type="radio" name="XingBie" value="男"/>男 <input type="radio" name="XingBie" checked="checked" value="女"/>女 </div><br> <div>选择生日 <input type="text" class=‘input‘ name="ShengRi"/></div><br> <div align="center"> <input class=‘ZhuCe‘ type="submit" name="ZhuCe" value="注册"/> <input class="ZhuCe" type="button" value="去登入" onclick="window.location.href=‘DengRu.php‘" </div> </form> <style type="text/css"> *{margin:0px; padding:0px;} form { position:absolute; top:10%; left:40%; width:235px; } .input { border:1px solid #0F0; width:150px; height:25px; } .ZhuCe { width:50px; height:25px; background-color:#3FC; color:#F00; } </style>
(账户管理)登入界面 DengRu.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>登入界面</title> <?php session_start(); if(!empty($_POST[‘DengRu‘])) { if(empty($_POST[‘ZhangHao‘])||empty($_POST[‘MiMa‘])) { echo"<script>alert(‘账号或密码不存在‘)</script>"; } else { $ZhangHao=$_POST[‘ZhangHao‘]; $MiMa=$_POST[‘MiMa‘]; include"class/uniondatabase-class.php"; $db=new unionDatabase(); $sql="select ZhuangTai from yonghu where ZhangHao=‘$ZhangHao‘ and MiMa=‘$MiMa‘"; $result=$db->queryStr($sql); echo $result; if($result==‘已激活‘) { $_SESSION[‘ZhangHao‘]=$ZhangHao; header(‘location:Main.php‘); } else { echo"<script>alert(‘账号或密码不存在‘)</script>"; } } } ?> <form action="" method="post"> <h1 align="center">登入界面</h1><br> <div>账户 <input class="input" type="text" name="ZhangHao"/></div><br> <div>密码 <input class="input" type="password" name="MiMa"/></div><br> <div align="center"> <input class="DengRu" type="submit" name="DengRu" value="登入"/> <input class="DengRu" type="button" value="去注册" onClick="window.location.href=‘ZhuCe.php‘"/> </div><br> </form> <style type="text/css"> *{margin:0px; padding:0px;} form { position:absolute; top:10%; left:40%; width:200px; } .input { border:1px solid #0F0; width:150px; height:25px; } .DengRu { width:50px; height:25px; background-color:#3FC; color:#F00; } </style>
(账户管理)管理界面 main.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>主界面</title> <?php session_start(); if(empty($_SESSION[‘ZhangHao‘])) header(‘location:DengRu.php‘); include"class/uniondatabase-class.php"; $db=new unionDatabase(); if(!empty($_GET[‘ZhangHao‘])) { $Zhanghao=$_GET[‘ZhangHao‘]; $Zhuangtai=$_GET[‘ZhuangTai‘]; if($Zhuangtai=="未激活") { $sql="update YongHu set ZhuangTai=‘已激活‘ where ZhangHao=‘$Zhanghao‘"; $db->query($sql); } else { $sql="update YongHu set ZhuangTai=‘未激活‘ where ZhangHao=‘$Zhanghao‘"; $db->query($sql); } } ?> <h1 align="center">账号管理</h1> <table align="center"> <tr> <td>账号</td> <td>密码</td> <td>姓名</td> <td>性别</td> <td>生日</td> <td>注册时间</td> <td>账号状态</td> </tr> <?php $sql="select * from YongHu"; $result=$db->query($sql); foreach($result as $i) { if($i[5]=="未激活") { $i[5]="<a href=‘main.php?ZhangHao=$i[0]&ZhuangTai=$i[5]‘>$i[5]</a>"; } else { $i[5]="<a href=‘main.php?ZhangHao=$i[0]&ZhuangTai=$i[5]‘>$i[5]</a>"; } echo"<tr> <td>$i[0]</td> <td>$i[1]</td> <td>$i[2]</td> <td>$i[3]</td> <td>$i[4]</td> <td>$i[6]</td> <td>$i[5]</td> </tr>"; } ?> </table> <style type="text/css"> table { position:absolute; top:70px; left:10%; border:1px solid #0F0; width:80%; text-align:center; } td { border:1px solid #0F0; text-align:center; } a { text-decoration:none; color:#F00; } a:hover { color:#00F; } </style>
以上是关于第七十五天上课 php注册登入审核和文件上传的主要内容,如果未能解决你的问题,请参考以下文章