Web网站实现简单的登录功能(php+mysql)

news/2024/5/9 19:39:31/文章来源:https://blog.csdn.net/qq_41106517/article/details/101083066

1.效果图——自我感觉还不算太难看hhhhh

2.完整代码

Index.php:

<!DOCTYPE html>
<html>
<head><meta name="content-type"; charset="UTF-8"><title>校园-监督人 登录</title><link rel="stylesheet" type="text/css" href="css/login.css"/><script src="js/jquery-3.3.1.js"></script><!--/背景的雪花动态样式--><script src="js/xuehua.js"></script><script>$(document).ready(function(e){     $(".yonghuming").click(function(){$("#fanhuizhi").hide();});$(".mima").click(function(){$("#fanhuizhi").hide();});      });</script>
</head>
<body><!--登录块开始--><form id="loginform" action="denglu/loginaction.php" autocomplete="off"  method="post"><img src="image/dump.svg" id="img_denglu"/><div class="login_div1"> <!--用户名块开始-->      <div class="yonghuming"><input type="text" id="name" class="input_yhm" name="username" required="required"placeholder="用户名"value="<?php echo isset($_COOKIE["test"])?$_COOKIE["test"]:"";?>"><img class="img_yhm" src="zhuce/yonghu.svg"/></div><div class="mima"><input type="password" id="password" placeholder="密码" class="input_mima" name="password"><img class="img_mima" src="zhuce/mima.svg"/></div><input type="submit" id="login" class="submit_login" name="login" value="登录"><!--返回登录状态--><div id="fanhuizhi">    <?php$err=isset($_GET["err"])?$_GET["err"]:"";switch($err){case 1:echo "用户名或密码错误!";break;case 2:echo "用户名或密码不能为空!";break;}?></div><div id="huanying">校园"监督人"&nbsp;&nbsp;欢迎你</div><a href="zhuce/register.php"><span id="zhucewenzi">注册</span></a></div></form>
</body>
</html>

login.css:

html{font-size: 62.5%;
}
*{margin: 0rem;padding: 0rem;
}
body{background-color: #1ABD9D;
}
.snow{position:fixed;top:0;color:#fff;z-index:99999999;
}
#img_denglu{position: absolute;width: 55vw;height: 400px;left: 6vw;top: 150px;
}
.login_div1{border-radius: 5px;position: absolute;top: 160px;background-color: white;left: 60vw;width: 30vw;height:360px;box-shadow: #009688 0px 0px 30px;
}
.yonghuming{top: 50px;border-radius: 5px;margin: 0 auto;background-color: white;width: 26vw;height: 50px;position: relative;/*overflow: hidden;*/
}
.input_yhm{position: absolute;border: 0;width: 21vw;height: 48px;left: 4vw;border-radius: 5px;margin: 0 auto;outline: none;color: gray;font-size: 20px;border: 1px solid gainsboro;
}
input {  filter: none !important;  } 
.img_yhm{top: 1px;left: 0.5vw;position: absolute;width: 40px;height: 50px;
}/*密码*/
.mima{top: 80px;border-radius: 5px;margin: 0 auto;background-color: white;width: 26vw;height: 50px;position: relative;/*overflow: hidden;*/
}
.input_mima{position: absolute;/*box-shadow: 0 0 20px 10px #fff inset;*/border: 0;width: 21vw;left: 4vw;height: 48px;border-radius: 5px;margin: 0 auto;outline: none;font-size: 20px;color: gray;border: 1px solid gainsboro;
}
.img_mima{top: 1px;left: 0.5vw;position: absolute;width: 40px;height: 50px;
}/*登录*/
.submit_login{position: absolute;margin: 0 auto;height: 50px;width: 22vw;top: 240px;left: 4vw;outline: none;background-color: #1ABD9D;border:0;font-size: 20px;border-radius: 5px;transition: 0.3s;color: white;
}
.submit_login:hover{color: black;font-weight: 500;transition: 0.3s;cursor:pointer;background-color: gainsboro;
}
#fanhuizhi{width: 30vw;height: 40px;position: relative;top: 90px;text-align: center;font-size:15px;line-height: 40px;color:#F04D4E;background-color: white;
}#huanying{position: absolute;width: 30vw;height: 40px;top: 310px;line-height: 40px;text-align: center;color:gainsboro;font-size: 14px;
}#fangxiang{position: absolute;width: 50px;height: 70px;left: 31vw;top: 340px;
}
#zhucewenzi{top: 320px;left: 26vw;width: 40px;height: 30px;font-size: 14px;position: absolute;color: gainsboro;
}
#zhucewenzi:hover{color: #1ABD9D;
}
input:-webkit-autofill {-webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
}

shujuku.php:

<?php
ini_set("error_reporting","E_ALL & ~E_NOTICE");
header("Content-Type: text/html;charset=utf-8");//连接数据库
$conn = mysqli_connect('localhost:3306','root','root','test');
?>

loginanction.php:

<?phpinclude_once("../shujuku.php");ini_set("error_reporting","E_ALL & ~E_NOTICE");header("Content-Type: text/html;charset=utf-8");//声明变量$username = isset($_POST['username'])?$_POST['username']:"";$password = isset($_POST['password'])?$_POST['password']:"";//判断用户名和密码是否为空if(!empty($username)&&!empty($password)) {//准备SQL语句$sql_select = "SELECT  id,username,password FROM user WHERE username = '$username' AND password = '$password'";//执行SQL语句$ret = mysqli_query($conn,$sql_select);$row = mysqli_fetch_array($ret);//判断用户名或密码是否正确if($username==$row['username']&&$password==$row['password']) {//开启sessionsession_start();//创建session$_SESSION['user']=$username;$_SESSION['id'] = $row['id'];//写入日志$ip = $_SERVER['REMOTE_ADDR'];$date = date('Y-m-d H:m:s');//跳转到登录成功所展示的页面header("Location:../zhuye/zhuye.php");//关闭数据库mysqli_close($conn);}else{//用户名或密码错误,赋值err为1header("Location:../index.php?err=1");}}else {//用户名或密码为空,赋值err为2header("Location:../index.php?err=2");}?>

数据库:

数据库名:test

表名:user

各属性值:

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_859816.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【微信小程序推广营销】教你微信小程序SEO优化,让你的小程序快人一步抢占先机...

今年一月份上线的小程序&#xff0c;经过近一年的沉淀发酵&#xff0c;现在也进入了快速发展期。 在未来肯定会有越来越多的小程序诞生&#xff0c;小程序多了就需要搜索&#xff0c;那么如何让自己的小程序在众多的小程序中脱颖而出&#xff0c;这就需要小程序SEO优化。 拼序网…

phpcms安装后网站首页跳转到Install/install/index.html怎么办?

1.删除根目录下的html 在文件夹caches里有一个install的文件最好也删除 2.清楚浏览器缓存&#xff0c;不会的可以百度一下&#xff0c;不同的浏览器清除缓存方式不同。 你若不想清除所有缓存&#xff0c;在全部那里可以设置时间段&#xff08;记住删除你安装phpcms时间段的缓…

phpcms网站后台以及前台提示信息不存在应该怎么解决

有时候前台与后台提示信息不存在大部分原因是因为路径不对&#xff0c;仔细看一下路径就会发现。 然后你需要让其展示静态的网页内容&#xff0c;内容→管理栏目→点进栏目之后生成html设置选择是即可

laravel写的大型招商类网站,带后端前台手机端,你值得拥有

laravel写的大型招商类网站&#xff0c;带后端前台手机端&#xff0c;你值得拥有 大型招商类型网站&#xff0c;再带后端、前台、wap #安装方式 $git clone https://github.com/imnotdoubi/dbzhaoshang1.git #注意事项 .env内容文件执行修改剩下的都用图来说明了。 #后台…

laravel-admin码的开源B2B电子商务行业门户网站后台系统

&#xff08;如果帮助了你&#xff0c;请给个Star&#xff09; laravel-admin码的B2B电子商务行业门户后台网站管理系统 开箱即用&#xff0c;当前已发布商城、会员、项目、文章、项目资讯、问答、供应管理、等模型 #安装方式 $git clone https://github.com/imnotdoubi/lar…

微信小程序延续laravel-adminB2B电子商务行业门户前端网站

laravel-admin 前端 微信小程序&#xff08;模版样式是随便弄了一个&#xff0c;将就看&#xff09; 开箱即用&#xff0c;当前已发布小程序首页&#xff0c;项目列表&#xff0c;项目内容&#xff0c;文章列表&#xff0c;内容&#xff0c;留言等配置<br> #安装方式 $…

laravel-admin写B2B电子商务行业门户前端网站系统

项目直通车&#xff1a;https://github.com/imnotdoubi/laravel-admin 如果帮助了你&#xff0c;请给个Star&#xff0c;感谢老铁&#xff01;&#xff01;&#xff01; laravel-admin项目已更新PC端预览&#xff0c;链接查看 http://47.98.200.91 后端查看链接&#xff1a;…

由于想强制自己不看某直播视频网站就写了一个小程序

由于想强制自己不看某直播视频网站就写了一个小程序 随意写了下&#xff0c;在自己的电脑上测试没问题&#xff0c; 这个可以提供给不会程序的人比如&#xff08;爸爸不想让儿子去某个网站购物&#xff0c;男友不让女友上某购物网站。&#xff09; 代码很简单&#xff0c; 核…

消除 cms网站系统的富编辑器中添加的img图片自动添加的高度

问题描述 由于网站是web端和wap响应式的&#xff0c;图片的宽度和高度都需要去掉才能保证wap端不变形。因此&#xff0c;需要将wap中的高度和宽度去掉 /* 所有图片最大宽度为全屏显示 */ .mainContent img{max-width:100%!important; } /* 所有图片高度去掉 */ .mainContent …

QQ于WEB网站接入流程详细

网站接入流程 网站通过以下几个步骤&#xff0c;即可接入互联开放平台&#xff1a; 开发者注册 > 网站申请 > 网站开发 > 调用OpenAPI 目录 [隐藏] 1. 开发者注册2. 网站接入申请 2.1 添加网站2.2 网站信息完善3. 网站开发 3.1 开发流程概述 3.1.1 网站上设置QQ登录入…

QQ对接WEB网站的SDK下载

SDK下载 目录 [隐藏] 注意事项SDK for 网站接入SDK for 移动应用接入 注意事项 温馨提示&#xff1a;2014年5月 Android_SDK 下载文档已做更新&#xff0c;请您到开放平台查看SDK文档。 腾讯QQ互联平台为广大开发者整理了以下SDK列表&#xff0c;辅助开发者快速接入QQ登录、分…

aws ec2服务上建立网站

一、申请账号&#xff0c;绑定信用卡 注册时会扣除一美元&#xff0c;并打电话确认。注册Amazon EC2 将自动的为你注册Amazon简单存储服务和Amazon虚拟私人云。这两个服务都被集合在Amazon EC2。如果你不使用这些服务&#xff0c;就不需要支付任何的费用。 二、登录https://co…

VUE(cli3.0) 使用prerender-spa-plugin + vue-meta-info做SEO和预渲染的效果及处理 prerender-spa-plugin 打包出错

prerender-spa-plugin vue-meta-info 做SEO和预渲染的效果 首先说说 prerender-spa-plugin 这玩意儿 这个就弄预渲染&#xff0c;好处就是预渲染可以极大的提高网页访问速度&#xff0c;配合一些meat插件&#xff0c;就可以可以满足SEO需求&#xff0c;尤其是开发到一半的项…

【转】为你的网站介绍 10 个非常有用的 jQuery 插件

文章转载自&#xff1a;开源中国社区 [ http://www.oschina.net ] 本文标题&#xff1a;为你的网站介绍 10 个非常有用的 jQuery 插件 本文地址&#xff1a;http://www.oschina.net/news/18514/10-very-useful-ajax-plugins-for-your-websites 1. AJAX-ZOOM 图像缩放 & …

12 个最好的免费网站速度和性能测试工具

如果你是位个人站长&#xff0c;就能理解网站速度的重要性。自从 Google 算法开始使用网页加载时间作为搜索排序参数之后&#xff0c;网站速度对 SEO 的影响非常大。而且&#xff0c;很慢的加载速度会对网站访问者产生消极的影响。如果你的网站加载速度很慢&#xff0c;需要等待…

Nginx主配置参数详解,Nginx配置网站

转自&#xff1a;http://www.cnblogs.com/hanyinglong/archive/2016/02/04/5141504.html 阅读目录 1.Niginx主配置文件参数详解2.Nginx.conf配置文件详细说明(附备注)3.Nginx代理网站 回到顶部 1.Niginx主配置文件参数详解 a.上面博客说了在Linux中安装nginx。博文地址为&#…

网站敏感词过滤

前言 前几天因为项目需要对用户回复内容进行敏感词过滤&#xff0c;所以我就去找了一下解决方案&#xff0c;在此记录下 博客地址 关于解决方案的选择 刚想到这个&#xff0c;先想到的就是把敏感词放到数组里面&#xff0c;循环遍历&#xff0c;判断文本中是否存在&#xff0c;…

TP5加支付宝手机网站支付配置

** TP5加支付宝手机网站支付配置 ** 调用支付宝接口的第一天&#xff1a; 之前申请审核手机网站弄了好久&#xff0c;不过审核还挺快的&#xff0c;一天内就审核好了&#xff0c;提交审核必须要有一个测试页面&#xff0c;测试页面中要有货名、单价、重量、合计&#xff0c;…

PHP支付宝手机网站支付notify异步通知

$config array (//应用ID,您的APPID。app_id > "",//商户私钥&#xff0c;您的原始格式RSA私钥merchant_private_key > "",//异步通知地址notify_url > "",//同步跳转return_url > "",//编码格式charset > "UTF-…

vue使用prerender-spa-plugin预渲染进行seo优化

前言 单页应用&#xff08;SPA&#xff09;是最近流行的一种应用模式&#xff0c;它支持在同一页面下通过哈希&#xff08;hash&#xff09;或html5的history api实现不刷新式切换视图&#xff0c;既实现了动态路由的变化&#xff0c;也实现了历史记录的保持&#xff0c;然而&a…