php mysql 留言本应用实例第1/2页
程序员文章站
2022-03-12 19:13:56
复制代码 代码如下:
<?php
$hostname_conn = "localhost";
$database_conn = "test";
$username_conn = "root";
$password_conn = "1981427";
$conn = mysql_connect($hostname_conn, $username_conn, $password_conn);
?>
<?php
//该函数用于将一般字符串转换成sql语句所需要的格式
function getsqlvaluestring($thevalue, $thetype)
{
$thevalue = (!get_magic_quotes_gpc()) ? addslashes($thevalue) : $thevalue;
switch ($thetype) {
case "text":
$thevalue = ($thevalue != "") ? "'" . $thevalue . "'" : "null";
break;
case "int":
$thevalue = ($thevalue != "") ? intval($thevalue) : "null";
break;
}
return $thevalue;
}
?>
<?php
session_start();
//如果session不存在,则跳转到admin.php
if (!(isset($_session['mm_username']))) {
header("location: admin.php");
exit;
}
?>
<?php require_once('connections/conn.php'); ?>
<?php
// *** validate request to login to this site.
session_start();
$loginformaction = $_server['php_self'];
if (isset($accesscheck)) {
$globals['prevurl'] = $accesscheck;
session_register('prevurl');
}
if (isset($_post['username'])) {
$loginusername=$_post['username'];
$password=$_post['password'];
$mm_flduserauthorization = "";
$mm_redirectloginsuccess = "adminmain.php";
$mm_redirectloginfailed = "admin.php";
$mm_redirecttoreferrer = false;
mysql_select_db($database_conn, $conn);
$loginrs__query=sprintf("select adminname, password from admin where adminname='%s' and password='%s'",
get_magic_quotes_gpc() ? $loginusername : addslashes($loginusername), get_magic_quotes_gpc() ? $password : addslashes($password));
$loginrs = mysql_query($loginrs__query, $conn) or die(mysql_error());
$loginfounduser = mysql_num_rows($loginrs);
if ($loginfounduser) {
$loginstrgroup = "";
//declare two session variables and assign them
$globals['mm_username'] = $loginusername;
$globals['mm_usergroup'] = $loginstrgroup;
//register the session variables
session_register("mm_username");
session_register("mm_usergroup");
if (isset($_session['prevurl']) && false) {
$mm_redirectloginsuccess = $_session['prevurl'];
}
header("location: " . $mm_redirectloginsuccess );
}
else {
header("location: ". $mm_redirectloginfailed );
}
}
?>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<title>untitled document</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style type="text/css"><!--
.style1 {font-size: 18px;
font-weight: bold;
}
.style2 {font-size: 14px}
--></style><style type="text/css" bogus="1">.style1 {font-size: 18px;
font-weight: bold;
}
.style2 {font-size: 14px}</style>
</head>
<body>
<p align="center"><span class="style1">留言板 - 管理登陆</span></p>
<p align="center"><span class="style2"><a href="viewposts.php" href="viewposts.php">浏览留言</a> | <a href="newpost.php" href="newpost.php">发表留言</a></span></p>
<form name="form1" method="post" action="<?php echo $loginformaction; ?>">
<table width="239" border="0" align="center">
<tr>
<td width="73">用户名:</td>
<td width="156"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="提交">
<input type="reset" name="submit2" value="重设"></td>
</tr>
</table>
</form>
<p align="center"> </p>
</body>
</html>
复制代码 代码如下:
<?php
$hostname_conn = "localhost";
$database_conn = "test";
$username_conn = "root";
$password_conn = "1981427";
$conn = mysql_connect($hostname_conn, $username_conn, $password_conn);
?>
复制代码 代码如下:
<?php
//该函数用于将一般字符串转换成sql语句所需要的格式
function getsqlvaluestring($thevalue, $thetype)
{
$thevalue = (!get_magic_quotes_gpc()) ? addslashes($thevalue) : $thevalue;
switch ($thetype) {
case "text":
$thevalue = ($thevalue != "") ? "'" . $thevalue . "'" : "null";
break;
case "int":
$thevalue = ($thevalue != "") ? intval($thevalue) : "null";
break;
}
return $thevalue;
}
?>
复制代码 代码如下:
<?php
session_start();
//如果session不存在,则跳转到admin.php
if (!(isset($_session['mm_username']))) {
header("location: admin.php");
exit;
}
?>
复制代码 代码如下:
<?php require_once('connections/conn.php'); ?>
<?php
// *** validate request to login to this site.
session_start();
$loginformaction = $_server['php_self'];
if (isset($accesscheck)) {
$globals['prevurl'] = $accesscheck;
session_register('prevurl');
}
if (isset($_post['username'])) {
$loginusername=$_post['username'];
$password=$_post['password'];
$mm_flduserauthorization = "";
$mm_redirectloginsuccess = "adminmain.php";
$mm_redirectloginfailed = "admin.php";
$mm_redirecttoreferrer = false;
mysql_select_db($database_conn, $conn);
$loginrs__query=sprintf("select adminname, password from admin where adminname='%s' and password='%s'",
get_magic_quotes_gpc() ? $loginusername : addslashes($loginusername), get_magic_quotes_gpc() ? $password : addslashes($password));
$loginrs = mysql_query($loginrs__query, $conn) or die(mysql_error());
$loginfounduser = mysql_num_rows($loginrs);
if ($loginfounduser) {
$loginstrgroup = "";
//declare two session variables and assign them
$globals['mm_username'] = $loginusername;
$globals['mm_usergroup'] = $loginstrgroup;
//register the session variables
session_register("mm_username");
session_register("mm_usergroup");
if (isset($_session['prevurl']) && false) {
$mm_redirectloginsuccess = $_session['prevurl'];
}
header("location: " . $mm_redirectloginsuccess );
}
else {
header("location: ". $mm_redirectloginfailed );
}
}
?>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<title>untitled document</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style type="text/css"><!--
.style1 {font-size: 18px;
font-weight: bold;
}
.style2 {font-size: 14px}
--></style><style type="text/css" bogus="1">.style1 {font-size: 18px;
font-weight: bold;
}
.style2 {font-size: 14px}</style>
</head>
<body>
<p align="center"><span class="style1">留言板 - 管理登陆</span></p>
<p align="center"><span class="style2"><a href="viewposts.php" href="viewposts.php">浏览留言</a> | <a href="newpost.php" href="newpost.php">发表留言</a></span></p>
<form name="form1" method="post" action="<?php echo $loginformaction; ?>">
<table width="239" border="0" align="center">
<tr>
<td width="73">用户名:</td>
<td width="156"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="提交">
<input type="reset" name="submit2" value="重设"></td>
</tr>
</table>
</form>
<p align="center"> </p>
</body>
</html>
1
上一篇: 曝屏下相机下半年可大规模量产!小米MIX4有望首发
下一篇: PHP HTML代码串 截取实现代码
推荐阅读
-
php mysql 留言本应用实例第1/2页
-
flash+php+mysql打造简单留言本教程第1/3页_PHP教程
-
apache php mysql php mysql 留言本应用实例第1/2页
-
apache php mysql php mysql 留言本应用实例第1/2页
-
flash player for mac flash+php+mysql打造简单留言本教程第1/3页
-
flash+php+mysql打造简单留言本教程第1/3页
-
flash+php+mysql打造简单留言本教程第1/3页
-
flash+php+mysql打造简单留言本教程第1/3页_PHP教程
-
flash player for mac flash+php+mysql打造简单留言本教程第1/3页
-
php mysql 留言本应用实例第1/2页