Php implements mysql database connection operations and user management, and mysql database connection. Php implements mysql database connection operations and user management, and a list of mysql database connection files .. File content .. Dbconn. phpuserListt. phpeditUser. phpeditDo. phpdetailUser. phpdelet php implements mysql database connection operations and user management, and mysql database connection
File list .. File content ..
Dbconn. php
UserListt. php
EditUser. php
EditDo. php
DetailUser. php
DeleteUser. php
AddUser. php
AddDo. php
<? Php // create a database connection $ con = mysql_connect ("localhost", 'root', '') or die ('Error :'. mysql_error (); mysql_select_db ('hyxx', $ con) or die ('Error :'. mysql_error (); mysql_query ('set NAMES utf8');?>
UserListt. php
Member Information List
Id |
User name |
Password |
Gender |
Age |
Date of birth |
Hobbies |
Registration time |
Last logon time |
Operation |
<? Phprequire_once 'Inc/dbConn. php'; // What is this .. Date_default_timezone_set ("PRC"); // read data... $ SQL = "select * from user order by id asc"; $ result = mysql_query ($ SQL, $ con); $ userList = ''; while ($ rs = mysql_fetch_array ($ result) {$ userList [] = $ rs;} // Loop user list foreach ($ userList as $ user) {echo"
". $ User ['id']." |
". $ User ['username']." |
". $ User ['password']." |
". $ User ['sex']." |
". $ User ['age']." |
". Date (" Y-m-d ", $ user ['birthday'])." |
". $ User ['hobby']." |
". Date (" Y-m-d ", $ user ['add _ time'])." |
". Date (" Y-m-d ", $ user ['last _ login'])." |
Add & nbsp delete & nbsp change & nbsp check |
";}?>
EditUser. php
Edit user<? Php require_once 'Inc/dbConn. php'; $ userId = $ _ GET ['id']; // What is this .. Date_default_timezone_set ("PRC"); // read data... $ SQL = "select * from user where id =". $ userId; $ result = mysql_query ($ SQL, $ con); $ user = mysql_fetch_array ($ result);?>
EditDo. php
<? Phprequire_once 'Inc/dbConn. php '; ////////////// /// // $ user_id = $ _ POST ['User _ id']; $ user_name = $ _ POST ['User _ name']; $ password = $ _ POST ['password']; if ($ _ POST ['sex'] = 'male') {$ sex = 1;} else if ($ _ POST ['sex'] = 'female ') {$ sex = 2;} else $ sex = 3; $ age = $ _ POST ['age']; $ birthday_y = $ _ POST ['birthday _ Y']; $ birthday_m = $ _ POST ['birthday _ m']; $ birthday_d = $ _ POST ['birthday _ d']; $ birthday = mktime (0, 0, 0, $ birthday_m, $ birthday_d, $ birthday_y); $ holobby =$ _ POST ['hobby']; $ profile =$ _ POST ['Profile ']; $ addTime = mktime (date ("h"), date ("m"), date ("s"), date ("m"), date ("d "), date ("Y"); $ lastLoginTime = $ addTime; $ SQL = "update user set username = '$ user_name', password = '$ password ', sex = '$ sex', age = '$ age', birthday =' $ birthday', holobby = '$ hoby ', profile = '$ profile' where id = '$ user_id' "; echo $ SQL; // execute the SQL statement mysql_query ($ SQL, $ con ); // Obtain the number of affected rows $ rows = mysql_affected_rows (); // return the number of affected rows. // if the number of affected rows is greater than or equal to 1, the value is successfully added, otherwise, if ($ rows> = 1) {alert ("edited successfully"); href ("userListt. php ");} else {alert (" edit failed "); // href (" addUser. php ");} function alert ($ title) {echo"