[小白的Web全栈之旅]独立开发电子商务网站--管理员后台开发(二、登入实现+管理商品【上】)

哈喽大家好,今天博主要讲解的是独立开发电子商务网站的第五篇——项目创建+数据库开发,想要预览整个系列博客的参考目录请点击这里

在本博客,博主会讲解:

  • 通过查询MySQL实现管理员登入
  • 查询已上架商品

 

通过查询MySQL实现管理员登入

之前的博客中,博主讲解了MySQL的基本操作,这里我们通过查询MySQL是否有匹配的管理员账号和密码来实现登入功能

请将以下代码覆盖到Admin.php文件:

<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>管理员后台</title>
		<!--调用Bootstrap-->
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
		<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
		<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
		<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
		
		<!--调用sweetAlert2-->
		<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
		
		<!--局内css-->
		<style>
			html,body{
				margin: 0;
				min-height: 100%;
			}
			a.nav-link{
				font-size: 19px;
			}
			a.dropdown-item{
				font-size: 15px;
			}
		</style>
		<script>
			function getCookie(name)
			{
    			var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    			if(arr=document.cookie.match(reg))
        			return unescape(arr[2]);
    			else
        			return null;
			}
			function delCookie(name)
			{
			    var exp = new Date();
				exp.setTime(exp.getTime() - 1);
    			var cval=getCookie(name);
    			if(cval!=null)
        			document.cookie= name + "="+cval+";expires="+exp.toGMTString();
			}
			function error(err){
				Swal.fire({
					type: 'error',
					title: '出错啦',
					text: err,
					confirmButtonText: '确定'
				});
				var timer=3;
				setInterval(function(){myTimer()},1000);
				function myTimer()
				{
					if(timer>0)
					{
		    			timer-=1;
					}
					else
					{
						window.location.href='Admin.php';
					}
				}
				delCookie('Admin');
				delCookie('Admin_Password');
			}
		</script>
	</head>
	<?php
	if(isset($_COOKIE['Admin']))
	{
		$usr = $_COOKIE['Admin'];
		$pwd = $_COOKIE['Admin_Password'];
	}
	elseif(isset($_POST['account']))
	{
		$usr = $_POST['account'];
		$pwd = $_POST['password'];
	}
	else
	{
	?>
	<body style="background-color:grey">
		<div  class="d-flex justify-content-center align-items-center" style="width:100%;height:100%;">
			<div style="width:50%;height:40%;background-color:#ffffff" class="d-flex justify-content-center align-items-center">
				<form style="width:90%;" method="post">
					<h3>管理员后台</h3>
					<div class="form-group">
						<label
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值