Phpmysql message book application example page 1/2 _ PHP Tutorial

Source: Internet
Author: User
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...

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.