⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.php

📁 希望这个对大家有用
💻 PHP
字号:
<?php require_once('Connections/vote.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['txtUsername'])) {
  $loginUsername=$_POST['txtUsername'];
  $password=$_POST['txtPassword'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "admin.php";
  $MM_redirectLoginFailed = "failure.php?err=1";
  $MM_redirecttoReferrer = true;
  mysql_select_db($database_vote, $vote);
  
  $LoginRS__query=sprintf("SELECT username, password FROM `admin` WHERE username=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $vote) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理员登录</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function checkFormData() {
  if ( form1.txtUsername.value == "" ) {
    alert ( "用户名不能为空,请输入用户名!" );
	form1.txtUsername.focus();
	return false;
  }
  if ( form1.txtPassword.value == "" ) {
    alert ( "密码不能为空,请输入密码!" );
	form1.txtPassword.focus();
	return false;
  }
}
</script>
</head>

<body>
<table width="96%" border="1" align="center" frame="below" rules="none">
<tr><td><a href="index.php"><img src="images/logo.gif" width="160" height="33" border="0" /></a></td>
  <td valign="bottom"><a href="index.php">系统首页</a></td>
  <td align="right" valign="bottom"><?php echo date("Y年n月j日"); ?>&nbsp;&nbsp;</td>
</tr>
</table>
<br />
&nbsp;&nbsp;当前位置:管理员登录
<form action="<?php echo $loginFormAction; ?>" method="POST" name="form1" id="form1" onsubmit="return checkFormData()">
<table width="300" border="1" align="center" rules="none">
  <tr bgcolor="#316ac5">
    <th colspan="2" bgcolor="#666666" class="title" scope="col">管理员登录</th>
  </tr>
  <tr>
    <td width="94" height="32" align="right">用户名:</td>
    <td width="190" height="32"><input name="txtUsername" type="text" id="txtUsername" /></td>
  </tr>
  <tr>
    <td align="right">密码:</td>
    <td><input name="txtPassword" type="password" id="txtPassword" /></td>
  </tr>
  <tr>
    <td height="32">&nbsp;</td>
    <td height="32"><input type="submit" name="Submit" value="登录" />
      &nbsp;&nbsp;
      <input type="reset" name="Submit2" value="重置" /></td>
  </tr>
</table>
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -