Php implements mysql database connection operations and user management. mysql database connection _ PHP Tutorial

Source: Internet
Author: User
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      
 
 <? 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" 
   ";}?> 
  
Id User name Password Gender Age Date of birth Hobbies Registration time Last logon time Operation
". $ 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"

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.