Php mysql message book application page 1/2

Source: Internet
Author: User
Tags php mysql

Copy codeThe Code is 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 codeThe Code is as follows: <? Php
// 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;
}
?>

Copy codeThe Code is as follows: <? Php
Session_start ();

// Jump to Admin. php if the Session does not exist
If (! (Isset ($ _ SESSION ['Mm _ username']) {
Header ("Location: admin. php ");
Exit;
}
?>

Copy codeThe Code is as follows: <? Php require_once ('ons ONS/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 ){
$ 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 );
}
}
?>
<! 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"> message board-management logon </span> </p>
<P align = "center"> <span class = "style2"> <a href = "viewposts. php "href =" viewposts. php "> browse messages </a> | <a href =" newpost. php "href =" newpost. php "> post a message </a> </span> </p>
<Form name = "form1" method = "POST" action = "<? Php echo $ loginFormAction;?> ">
<Table width = "239" border = "0" align = "center">
<Tr>
<Td width = "73"> User name: </td>
<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 = "Submit" value = "submit">
<Input type = "reset" name = "Submit2" value = "reset"> </td>
</Tr>
</Table>
</Form>
<P align = "center"> </p>
</Body>
</Html>

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.