Phpmysql message book application page 1. Copy the code as follows :? Php $ hostname_connlocalhost; $ database_conntest; $ username_connroot; $ password_conn1981427; $ connmysql_connect ($ hostname_conn, $ u
The code is as follows:
$ Hostname_conn = "localhost ";
$ Database_conn = "test ";
$ Username_conn = "root ";
$ Password_conn = "1981427 ";
$ Conn = mysql_connect ($ hostname_conn, $ username_conn, $ password_conn );
?>
The code is as follows:
// This function is used to convert a general string to the format required by an SQL statement.
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;
}
?>
The code is as follows:
Session_start ();
// Jump to Admin. php if the Session does not exist
If (! (Isset ($ _ SESSION ['Mm _ username']) {
Header ("Location: admin. php ");
Exit;
}
?>
The code is as follows:
// *** 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 ){
$ Logtailgroup = "";
// Declare two session variables and assign them
$ GLOBALS ['Mm _ username'] = $ loginUsername;
$ GLOBALS ['Mm _ usergroup'] = $ logtailgroup;
// 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 );
}
}
?>
Untitled Document
Message board-management login
Browse messages | post messages
The http://www.bkjia.com/PHPjc/319884.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319884.htmlTechArticle code is as follows :? Php $ hostname_conn = "localhost"; $ database_conn = "test"; $ username_conn = "root"; $ password_conn = "1981427"; $ conn = mysql_connect ($ hostname_conn, $ u...