<html>
<head>
<title>CoralCarol</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="img/favicon.ico" type="image/x-icon" rel="shortcut icon" />
<link rel="stylesheet" type="text/css" href="css/index.css">
<script type="text/javascript" src="js/index.js"></script>
<style type="text/css">
#body{
background: url(img/6598290224564091643.jpg) no-repeat;
background-repeat:no-repeat;
opacity: 1;
width: 100%;
height: auto;
margin-left: -800px;
margin-top: -1200px;
visibility: visible;
}
#login{
background-image: url(img/login.png) ;
width: 347px;
height: 218px;
margin-left: 90%;
margin-top: 90%;
position: absolute;
}
.email{
width: auto;
height: auto;
margin-left: 15%;
margin-top: 14%;
position: absolute;
}
#sub{
width: auto;
height: auto;
margin-left: 34%;
margin-top: 166px;
float: left;
position: relative;
}
.res{
width: auto;
height: auto;
margin-top: 150px;
margin-left: 2px;
float: left;
position: relative;
}
#footer{
width: 100%;
height: 20px;
margin-top: 120%;
margin-left: 50%;
position: absolute;
}
a:link,a:visited{
text-decoration:none;
}
a:hover{
text-decoration:none;
color:red;
}
td, th {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 24px;
color: #333333;
}
</style>
<!--邮箱/密码登录验证-->
<script type="text/javascript">
function IsDigit(cCheck)
{
return (('0'<=cCheck) && (cCheck<='9'));
}
function IsAlpha(cCheck)
{
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
}
function IsValid()
{
var struserName = reg.UserName.value;
for (nIndex=0; nIndex<struserName.length; nIndex++)
{
cCheck = struserName.charAt(nIndex);
if (!(IsDigit(cCheck) || IsAlpha(cCheck)))
{
return false;
}
}
return true;
}
function chkEmail(str)
{
return str.search(/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/)==0?true:false
}
function docheck()
{
if(reg.Email.value=="")
{
alert("请填写您的邮箱");
return false;
}
else if(!chkEmail(reg.Email.value))
{
alert("请填写有效的Email地址");
return false;
}
else if(reg.UserPassword.value=="")
{
alert("请填写您的密码");
return false;
}
else
{
return true;
}
}
/*重置对象内容*/
function formReset()
{
document.getElementById("myForm").reset()
}
</script>
</head>
<body id="body" link="#fff" alink="red" vlink="red">
<center>
<div id="login">
<form name="reg" action="./php/login.php" method="post" target="_self" onSubmit="return docheck()" id="myForm">
<div class="email">
<b>
<p>Email:
<td width="15px" align="left" height="23">
<input type="text" name="Email" placeholder="请输入您的登录邮箱地址"/>
</td>
</p>
<p>密 码:
<td width="15px" align="left" height="23">
<input type="password" name="UserPassword" placeholder="请输入您的登录邮箱密码"/>
</td>
</p>
</b>
</div>
<div id="sub"><input type="submit" name="sub" value="登录"></div>
</form>
<div class="res"><a href="regist.html"><input name="" type="submit" value="注册"></a></div>
<div class="res"><input type="button" onclick="formReset()" value="重置"></div>
</div>
</center>
<center>
<div id="footer">
<font color="#fff" style="楷体">
<span>CoralCarol公司版权所有</span>
<span>©1997-2013</span>
<span>粤ICP备200120404号</span>
<a target="_blank" href="#">反馈</a>
<span>|</span>
<a target="_blank" href="#">客户端</a>
<a target="_blank" href="#">关于</a>
<a target="_blank" href="#">商务合作</a>
<a target="_blank" href="#">官方博客</a>
<a target="_blank" href="#">官方微博</a>
</font>
</div>
</center>
</body>
</html>
/*登录页面后台验证login.php*/
<html>
<head>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<link href="../img/favicon.ico" type="image/x-icon" rel="shortcut icon" />
<title>商品信息管理登陆</title>
</head>
<body>
<?php
error_reporting(0);
$mysql_servername = "localhost"; //主机地址
$mysql_username = "root"; //数据库用户名
$mysql_password =""; //数据库密码
$mysql_database ="demodb"; //数据库
/*mysql_connect($mysql_servername , $mysql_username , $mysql_password);*/
$con = mysql_connect($mysql_servername , $mysql_username , $mysql_password);
mysql_select_db($mysql_database);
$Email=$_POST['Email'];
$UserPassowrd=$_POST['UserPassword'];
if ($Email && $UserPassowrd){
/*$sql = "SELECT Email FROM customs WHERE Email = '$Email' and UserPassword='$UserPassword'";*/
$sql = "SELECT Email FROM customs WHERE Email = '$Email' and UserPassword='$UserPassowrd'";
/*$res = mysql_query($sql);*/
$res = mysql_query($sql,$con);
$row = mysql_fetch_assoc($res);
print_r($row);
if($row['Email']==$Email){
setcookie("userid",$Email);
header("location:add.php");//跳转页面,注意路径
exit;
}
else{
echo "<script>";
echo "alert('对不起,您输入的用户不存在!请重新登录!')";
echo "</script>";
echo "<script>";
echo "window.location.href='../index.html'";
echo "</script>";
}
}
?>
</body>
</html>