File List ... File contents ...
dbconn.php
userlistt.php
edituser.php
editdo.php
detailuser.php
deleteuser.php
adduser.php
adddo.php
<dbconn.php>
<?php
//CREATE 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
<html> <head> <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "> <title> member Information list </title> </head> <body> <table border=" 1 "cellspacing=" 0 " cellpadding= "0" id= "userlist" align= "center" > <tr align= "center" > <td>id</td> <td> User name </td> <td> password </td> <td> sex </td> <td> age </td> <td> Birth date </t d> <td> Hobbies </td> <td> registration time </td> <td> Last login time </td> <td> operation </td>
;
</tr> <?php require_once ' inc/dbconn.php ';
What is this stuff?
Date_default_timezone_set ("PRC");
Read the 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 <tr> <td& gt; ". $user [' id ']."</td> <td> " $user [' username ']. " </td> <td> "$user [' Password ']." </td> <td> "$user [' sex ']." </td> <td> ". $user [' age ']." </td> <td> ". Date (" y-m-d ", $user [' Birthday '])." </td> <td> "$user [' hobby ']." </td> <td> ". Date (" y-m-d ", $user [' Add_time '])." </td> <td> ". Date (" y-m-d ", $user [' Last_login '])." </td> <td> <a href= ' adduser.php ' > Add </a> <a href= ' deleteuser.ph P?id= ". $user [' id ']." '); \ " >&nbsp Delete </a> <a href= ' edituser.php?id= '. $user [' id ']. "'); \" >&nbsp </a> <a href= ' detailuser.php?id= '. $user [' id ']. "'); \"
>&NBSP Check </a> </td> </tr> "; }?> </table>
</body> </html>
Edituser.php
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> Edit user </title> </head> <body> <?php require_once ' inc/dbconn.php
';
$userId =$_get[' id '];
What is this stuff?
Date_default_timezone_set ("PRC");
Read the data ...
$sql = "SELECT * from user where id=". $userId;
$result = mysql_query ($sql, $con); $user = Mysql_fetch_array ($result);?> <form action= "editdo.php" method= "POST" > <input type= "hidden" name= "user_id" value= "<?php echo $user [' id ']?>"/> <table width= "444" border= "1" align= "Center" > <t R> <td> username </td> <td> <input type= "text" name= "user_name" size= "ten" value=< ;? PHP echo $user [' username ']?>/></td> </tr> <tr> <TD≫ password </td> <td> <input type= "password" name= "password" size= "ten" value=<?php echo $user [' pas Sword ']?>/></td> </tr> <tr> <td> sex </td> <td>&nb Sp;<input type= "Radio" name= "Sex" value= "male" <?php if ($user [sex]== ' 1 ') echo "checked=\" checked\ ""?>/> ; Male <input type= "Radio" name= "Sex" value= "female" <?php if ($user [sex]== ' 2 ') echo "checked=\" checked\ ""?>/> Women </td> </tr> <tr> <td> age </td> <td> <input type=
"Text" name= "Age" size= "3" value=<?php echo $user [' age ']?>/></td> </tr> <tr> <td> Date of birth </td> <td> <!--1. The date of the year was obtained. 2. The corresponding date ...
You know the--> <?php $birday _y=date ("y", $user [' birthday ']);
$birday _m=date ("M", $user [' birthday ']);
$birday _d=date ("D", $user [' birthday ']); ?> <select name= "birthday_y" > <option value= "1980" <?php if ($birday _y==1980) echo "s Elected=\ "selected\" "?> >1980</option> <option value=" 1981 "<?php if ($birday _y==1981) echo" Selected=\ "selected\" "?> >1981</option> <option value=" 1982 "<?php if ($birday _y==1982) echo "Selected=\" selected\ ""?> >1982</option> <option value= "1983" <?php if ($birday _y==1983) echo "Selected=\" selected\ "?> >1983</option> <option value=" 1984 "<?php if ($birday _y==1984) Ech O "selected=\" selected\ ""?> >1984</option> <option value= "1985" <?php if ($birday _y==1985) EC Ho "selected=\" selected\ "?> >1985</option> <option value=" 1986 "<?php if ($birday _y==1986) E Cho "selected=\" selected\ ""?> >1986</option> <option value= "1987" <?php if ($birday _y==1987) echo "Selected=\" selecteD\ ""?> >1987</option> <option value= "1988" <?php if ($birday _y==1988) echo "selected=\" select Ed\ "";?> >1988</option> <option value= "1989" <?php if ($birday _y==1989) echo "Selected=\" Selec Ted\ "";?> >1989</option> <option value= "1990" <?php if ($birday _y==1990) echo "Selected=\" Sele
Cted\ ""?> >1990</option> </select> year <select name= "Birthday_m" >
<option value= "1" <?php if ($birday _m==1) echo "selected=\" selected\ "";?> >1</option> <option value= "2" <?php if ($birday _m==2) echo "selected=\" selected\ "";?> >2</option> <opti On value= "3" <?php if ($birday _m==3) echo "selected=\" selected\ ""?> >3</option> <option value = "4" <?php if ($birday _m==4) echo "selected=\" selected\ "?> >4</option> <option" 5 " ;? PHP if ($birday _m==5) ECho "selected=\" selected\ ""?> >5</option> <option value= "6" <?php if ($birday _m==6) echo "SEL" Ected=\ "selected\" "?> >6</option> <option value=" 7 "<?php if ($birday _m==7) echo" Selected=\ " Selected\ "";?> >7</option> <option value= "8" <?php if ($birday _m==8) echo "Selected=\" selected \ "";?> >8</option> <option value= "9" <?php if ($birday _m==9) echo "selected=\" selected\ "";? &G T >9</option> <option value= "Ten" <?php if ($birday _m==10) echo "selected=\" selected\ "";?> >10 </option> <option value= "One" <?php if ($birday _m==11) echo "selected=\" selected\ ""?> >11</ Option> <option value= "a" <?php if ($birday _m==12) echo "selected=\" selected\ "";?> >12</optio n> </select> Month <select name= "Birthday_d" > <option value= "1" ;? PHP if ($birday _d==1echo "selected=\" selected\ "?> >1</option> <option value=" 2 "<?php if ($birday _d==2) echo" Selected=\ "selected\" "?> >2</option> <option value=" 3 "<?php if ($birday _d==3) echo" Selected =\ "selected\" "?> >3</option> <option value=" 4 "<?php if ($birday _d==4) echo" Selected=\ "Selec Ted\ "";?> >4</option> <option value= "5" <?php if ($birday _d==5) echo "selected=\" selected\ ""; ?> >5</option> <option value= "6" <?php if ($birday _d==6) echo "selected=\" selected\ "";?> &G t;6</option> <option value= "7" <?php if ($birday _d==7) echo "selected=\" selected\ ""?> >7</ option> <option value= "8" <?php if ($birday _d==8) echo "selected=\" selected\ ""?> >8</OPTION&G
T <option value= "9" <?php if ($birday _d==9) echo "selected=\" selected\ "";?> >9</option> <opti On value= "10 "<?php if ($birday _d==10) echo" selected=\ "selected\";?> >10</option> <option value= "one" &L t;? PHP if ($birday _d==11) echo "selected=\" selected\ ";?> >11</option> <option value=" "<?php I F ($birday _d==12) echo "selected=\" selected\ "";?> >12</option> <option value= "<?php" if ($bi rday_d==13) echo "selected=\" selected\ "?> >13</option> <option value=" "<?php if ($birday _ D==14) echo "selected=\" selected\ "?> >14</option> <option value=" "<?php if ($birday _d==15 echo "selected=\" selected\ "?> >15</option> <option value=" "<?php if ($birday _d==16) Ech O "selected=\" selected\ "?> >16</option> <option value=" "<?php if ($birday _d==17) echo" se Lected=\ "selected\" "?> >17</option> <option value=" "<?php if ($birday _d==18) echo" selecte D=\ "selected\" ";; >18</option> <option value= "<?php if ($birday _d==19) echo" selected=\ "selected\" ";?> >1 9</option> <option value= "<?php if ($birday _d==20) echo" selected=\ "selected\" ";?> >20< /option> <option value= "<?php if ($birday _d==21) echo" selected=\ "selected\" ";?> >21</opti on> <option value= "<?php if" ($birday _d==22) echo "selected=\" selected\ ""?> >22</option>
; <option value= "<?php if" ($birday _d==23) echo "selected=\" selected\ "";?> >23</option> <o Ption value= "<?php if" ($birday _d==24) echo "selected=\" selected\ "";?> >24</option> <option Value= "<?php if ($birday _d==25) echo" selected=\ "selected\";?> >25</option> <option Valu E= "<?php if ($birday _d==26) echo" selected=\ "selected\" ";?> >26</option> <option value=" 27 "<?php if ($birday _d==27) echo "selected=\" selected\ "";?> >27</option> <option value= "a" <?php if ($ birday_d==28) echo "selected=\" selected\ "?> >28</option> <option value=" "<?php if ($birda y_d==29) echo "selected=\" selected\ ""?> >29</option> <option value= "a" <?php if ($birday _d== echo "selected=\" selected\ "?> >30</option> <option value=" to "<?php if ($birday _d==31) E
Cho "selected=\" selected\ "";?> >31</option> </select> Day </td> </tr> <tr> <td> Hobby </td> <td> <input type= "text" name= "hobby" s Ize= "value=<?php" echo $user [' hobby ']?>/></td> </tr> <tr> <td> Biography </td> <td> <textarea name= "profile" rows= "cols=" ><?php echo $user [' Profiles '] ?> </textarea> </td> </tr> <tr> <td colspan= "2" align= "center" ><input type= "Submit" V alue= "Confirm modification"/></td> </tr> </table> <p> </p> <p> </
p> <p> </p> </form> </body> </html>
Editdo.php
<?php require_once ' inc/dbconn.php ';
Get user information////////////////////$user _id = $_post[' user_id '];
$user _name = $_post[' user_name '];
$password = $_post[' password '];
if ($_post[' sex ']== ') {$sex =1;} else if ($_post[' sex ']== ' woman ') {$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);
$hobby = $_post[' hobby '];
$profile = $_post[' profile '];
$addTime =mktime ("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 ', hobby
= ' $hobby ', profile= ' $profile ' where id= ' $user _id ';
Echo $sql;
Execute SQL statement mysql_query ($sql, $con);
Gets the number of rows affected $rows = Mysql_affected_rows ();
Returns the affect number of rows//If the number of rows is affected, the >=1 is added successfully, otherwise the failure if ($rows >= 1) {alert ("Edit succeeded"); href ("Userlistt.php ");
}else{alert ("Edit failed");//href ("adduser.php"); Function alert ($title) {echo "<script type= ' text/javascript ' >alert (' $title ');</script>";} function href ($url)
{echo ' <script type= ' text/javascript ' >window.location.href= ' $url ' </script> ';}
?>
Detailuser.php
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> View user Details </title> </head> <body> <?php require_once ' inc/
Dbconn.php ';
$userId =$_get[' id '];
What is this stuff?
Date_default_timezone_set ("PRC");
Read the data ...
$sql = "SELECT * from user where id=". $userId;
$result = mysql_query ($sql, $con);
$user = Mysql_fetch_array ($result);?> <table width= "444" border= "1" align= "Center" > <tr> <td> User ID </td> <td> <?php echo $userId?> </td> </tr>
;tr> <td> username </td> <td> <?php echo $user [' username ']?> </td> </tr> <tr> <td> password </td> <td> <?php echo $user[' password ']?> </td> </tr> <tr> <td> sex </td> <td> <?php if ($user [sex]== ' 1 ') echo "male"; else if ($user [sex]== ' 2 ') echo "female"; else "confidentiality";?> </td> </tr> <tr> <td> age </td> <TD&G t; <?php echo $user [' age ']?> </td> </tr> <tr> <td> Birth </td>
; <td> <!--1. The date of the year was obtained. 2. The corresponding date ... You know the--> <?php $birday _y=date ("y", $user [' birthday ']); Echo $birday _y. "
Years "; $birday _m=date ("M", $user [' birthday ']); Echo $birday _m. "
Month "; $birday _d=date ("D", $user [' birthday ']); Echo $birday _d. "
Day "; ?> </td> </tr> <tr> <td> Hobby </td> <td> < ;? PHP echo $user [' hobby ']?> </td> </tr> <tr> <td> personal profile </td> & lt;! -can also box up ≪td> <textarea name= "Profile" rows= "the cols=" readonly><?php echo $user [' profile ']?> </ textarea> </td>--> <td> <?php echo $user [' profile ']?> </td> </tr>
;
<tr> <td colspan= "2" align= "center" ><a href= "userlistt.php" > Return to User list </a></td> </tr> </table> <p> </p> <p> </p> <p> </p&
Gt
</body> </html>
deleteuser.php
<?php
//contains database files
require_once ' inc/dbconn.php ';
Gets the deleted id
$id = $_get[' id '];
$row = Delete ($id, $con);
if ($row >=1) {
alert ("Delete succeeded");
} else{
alert ("Delete failed");
}
Jump to the User List page
href ("userlistt.php");
function Delete ($id, $con) {
$sql = "Delete from user where id= ' $id '";
Perform deletion
of mysql_query ($sql, $con);
Gets the number of rows affected
$rows = Mysql_affected_rows ();
Returns the effect of rows return
$rows
;
Function alert ($title) {
echo "<script type= ' text/javascript ' >alert (' $title ');</script>";
}
function href ($url) {
echo "<script type= ' text/javascript ' >window.location.href= ' $url ' </script>";
}
?>
adduser.php
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> new users </title> </head> <body> <form action=" adddo.php "method=" Post "> <input type=" hidden "name=" user_id "value=" "/> <table width=" 444 "border=" 1 "align=" center "> <tr> <td> User name </td> <td> <input type=" text "Name=" user_name "s Ize= "Ten"/></td> </tr> <tr> <td> password </td> <td> < ; input type= "password" name= "password" size= "ten"/></td> </tr> <tr> <td> Don't </td> <td> <input type= "Radio" name= "Sex" value= "male" checked= "checked"/> Male <input type= " Radio "name=", "Sex" value= "female" /> Women </td> </tr> <tr> <td> age </td> <td> <inpu
T type= "text" name= "Age" size= "3"/></td> </tr> <tr> <td> Birth date </td> <td> <select name= "birthday_y" > <option value= "1980" >1980</OPTION&G
T <option value= "1981" >1981</option> <option value= "1982" >1982</option> <opti On Value= "1983" >1983</option> <option value= "1984" >1984</option> <option value = "1985" >1985</option> <option value= "1986" >1986</option> <option value= "1987" & Gt;1987</option> <option value= "1988" >1988</option> <option value= "1989" >1989& Lt;/option> <option value= "1990" >1990</option> </select> year &L T;select NAMe= "Birthday_m" > <option value= "1" >1</option> <option value= "2" >2</option> <option value= "3" >3</option> <option value= "4" >4</option> <option Value= "5" >5</option> <option value= "6" >6</option> <option value= "7" >7</
option> <option value= "8" >8</option> <option value= "9" >9</option> <option value= "A" >10</option> <option value= "One" >11</option> <option Valu E= "A" >12</option> </select> month <select name= "Birthday_d" > ; option value= "1" >1</option> <option value= "2" >2</option> <option value= "3"
;3</option> <option value= "4" >4</option> <option value= "5" >5</option> <option value= "6" >6</option> <option value= "7" >7</option> <option value= "8" >8</option > <option value= "9" >9</option> <option value= "Ten" >10</option> ; option value= "one" >11</option> <option value= ">12</option> <option value=" 1 3 ">13</option> <option value=" >14</option> <option value= ">15</opt"
ion> <option value= ">16</option> <option value=" >17</option> <option value= "A" >18</option> <option value= "A" >19</option> <option val Ue= ">20</option> <option value=" >21</option> <option value= ">22<"
;/option> <option value= "a" >23</option> <option value= "a" >24</option> <option value=">25</option> <option value=" >26</option> <option value= ">27</o"
Ption> <option value= "a" >28</option> <option value= "a" >29</option> <option value= ">30</option> <option value=" >31</option> </select&
Gt Day </td> </tr> <tr> <td> Hobby </td> <TD>&NBSP;<INP UT type= "text" name= "hobby" size= "/></td> </tr> <tr> <td> Personal Profile </td&
Gt
<td> <textarea name= "Profile" rows= "ten" cols= "></textarea></td> </tr> <tr> <td colspan= "2" align= "center" ><input type= "Submit" value= "Add user"/></td> </tr&
Gt </table> <p> </p> <p> </p> <p> </p> </form> </body> </html>
Adddo.php
<?php require_once ' inc/dbconn.php ';
Get user information////////////////////$user _id = $_post[' user_id '];
$user _name = $_post[' user_name '];
echo $user _name;
$password = $_post[' password '];
if ($_post[' sex ']== ') {$sex =1;} else if ($_post[' sex ']== ' woman ') {$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);
$hobby = $_post[' hobby '];
$profile = $_post[' profile '];
$addTime =mktime ("H"), Date ("M"), date ("s"), date ("M"), Date ("D"), Date ("Y"));
$lastLoginTime = $addTime;
$sql = INSERT INTO User (Username,password,sex,age,birthday,hobby,profile,add_time,last_login).
"Values (' $user _name ', ' $password ', ' $sex ', ' $age ', ' $birthday ', ' $hobby ', ' $profile ', ' $addTime ', ' $lastLoginTime ')";
Echo $sql;
Execute SQL statement mysql_query ($sql, $con);
Gets the number of rows affected $rows = Mysql_affected_rows (); Returns the number of rows affected//If the number of rows is >=1,Add success, otherwise failure if ($rows >= 1) {alert ("Add success");
href ("userlistt.php");
}else{alert ("Add failed");//href ("adduser.php"); Function alert ($title) {echo "<script type= ' text/javascript ' >alert (' $title ');</script>";} function href ($url)
{echo ' <script type= ' text/javascript ' >window.location.href= ' $url ' </script> ';}
?>