PHP MySQL Message This application example 1th/2 page _php instance

Source: Internet
Author: User
Tags php mysql
Copy Code code as follows:

<?php
$hostname _conn = "localhost";
$database _conn = "Test";
$username _conn = "root";
$password _conn = "1981427";
$conn = mysql_connect ($hostname _conn, $username _conn, $password _conn);
?>

Copy Code code as follows:

<?php
This function is used to convert a generic string into a format required for SQL statements
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;
}
?>

Copy Code code as follows:

<?php
Session_Start ();

If the session does not exist, jump to admin.php
if (!) ( Isset ($_session[' mm_username '))) {
Header ("Location:admin.php");
Exit
}
?>

Copy Code code as follows:

<?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" >
<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>

<body>
<p align= "center" ><span class= "style1" > Message board-Admin login </span></p>
<p align= "center" ><span class= "Style2" ><a href= "viewposts.php" href= "viewposts.php" > Browse message </a > | <a href= "newpost.php" href= "newpost.php" > Post message </a></span></p>
<form name= "Form1" method= "POST" action= "<?php echo $loginFormAction;?>" >
<table width= "239" border= "0" align= "center" >
<tr>
&LT;TD width= > Username:</td>
&LT;TD width= "156" ><input name= "username" type= "text" id= "username" ></td>
</tr>
<tr>
<td> Password:</td>
<td><input name= "password" type= "password" id= "password" ></td>
</tr>
<tr>
<td> </td>
<td><input type= "Submit" name= "Submission" value= "submitted" >
<input type= "reset" name= "Submit2" value= "reset" ></td>
</tr>
</table>
</form>
<p align= "center" > </p>
</body>

Current 1/2 page 12 Next read the full text

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.