PHP
·
发表于 5年以前
·
阅读量:8296
ÎļþÁбi¡£¡£ÎļþÄÚÈÝ¡£¡£
dbconn.php
userListt.php
editUser.php
editDo.php
detailUser.php
deleteUser.php
addUser.php
addDo.php
<?php
// ´´½¨Êý¾Ý¿aÁ¬½Ó
$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');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>»aÔ±ÐÅÏ¢Áбi</title>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="0" id="userList" align="center">
<tr align="center">
<td>id</td>
<td>Óû§Ãu</td>
<td>ÃÜÂe</td>
<td>ÐÔ±ð</td>
<td>ÄeÁa</td>
<td>³oÉuÄeÔÂ</td>
<td>°®ºÃ</td>
<td>×¢²aʱ¼a</td>
<td>×iºoµÇ¼ʱ¼a</td>
<td>²Ù×÷</td>
</tr>
<?php
require_once 'inc/dbConn.php';
//ÕaÊÇɶ¶«¶«¡£¡£
date_default_timezone_set("PRC");
//¶ÁÊý¾Ý¡£¡£¡£
$sql = "select * from user order by id asc";
$result = mysql_query($sql,$con);
$userList = '';
while($rs = mysql_fetch_array($result)){
$userList[] = $rs;
}
// Ñ»*Óû§Áбi
foreach ($userList as $user){
echo "
<tr>
<td> ".$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'>Ôo</a>
<a href='deleteUser.php?id=".$user['id']."');\"> ɾ</a>
<a href='editUser.php?id=".$user['id']."');\"> ¸Ä</a>
<a href='detailUser.php?id=".$user['id']."');\"> ²e</a>
</td>
</tr>
";
}
?>
</table>
</body>
</html>
<!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>±a¼Óû§</title>
</head>
<body>
<?php
require_once 'inc/dbConn.php';
$userId=$_GET['id'];
//ÕaÊÇɶ¶«¶«¡£¡£
date_default_timezone_set("PRC");
//¶ÁÊý¾Ý¡£¡£¡£
$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">
<tr>
<td>Óû§Ãu </td>
<td> <input type="text" name="user_name" size="10" value=<?php echo $user['username'] ?> /></td>
</tr>
<tr>
<td>ÃÜÂe</td>
<td> <input type="password" name="password" size="10" value=<?php echo $user['password'] ?> /></td>
</tr>
<tr>
<td>ÐÔ±ð</td>
<td> <input type="radio" name="sex" value="ÄÐ"
<?php if($user[sex]=='1') echo "checked=\"checked\"" ?> /> ÄÐ<input type="radio" name="sex" value="Å®" <?php if($user[sex]=='2') echo "checked=\"checked\"" ?>
/> Å® </td>
</tr>
<tr>
<td>ÄeÁa</td>
<td> <input type="text" name="age" size="3" value=<?php echo $user['age'] ?> /></td>
</tr>
<tr>
<td>³oÉuÄeÔÂ</td>
<td>
<!-- 1¡£È¡µÃÄeÔÂÈÕ¡£2¡£ÏaÓ¦µÄÄeÔÂÈÕ¡£¡£¡£Äa¶®µÄ -->
<?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 "selected=\"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) echo "selected=\"selected\""; ?> >1984</option>
<option value="1985" <?php if($birday_y==1985) echo "selected=\"selected\""; ?> >1985</option>
<option value="1986" <?php if($birday_y==1986) echo "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=\"selected\""; ?> >1988</option>
<option value="1989" <?php if($birday_y==1989) echo "selected=\"selected\""; ?> >1989</option>
<option value="1990" <?php if($birday_y==1990) echo "selected=\"selected\""; ?> >1990</option>
</select>
Äe
<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>
<option 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 value="5" <?php if($birday_m==5) echo "selected=\"selected\""; ?> >5</option>
<option value="6" <?php if($birday_m==6) echo "selected=\"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\""; ?> >9</option>
<option value="10" <?php if($birday_m==10) echo "selected=\"selected\""; ?> >10</option>
<option value="11" <?php if($birday_m==11) echo "selected=\"selected\""; ?> >11</option>
<option value="12" <?php if($birday_m==12) echo "selected=\"selected\""; ?> >12</option>
</select>
ÔÂ
<select name="birthday_d">
<option value="1" <?php if($birday_d==1) echo "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=\"selected\""; ?> >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\""; ?> >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>
<option value="9" <?php if($birday_d==9) echo "selected=\"selected\""; ?> >9</option>
<option value="10" <?php if($birday_d==10) echo "selected=\"selected\""; ?> >10</option>
<option value="11" <?php if($birday_d==11) echo "selected=\"selected\""; ?> >11</option>
<option value="12" <?php if($birday_d==12) echo "selected=\"selected\""; ?> >12</option>
<option value="13" <?php if($birday_d==13) echo "selected=\"selected\""; ?> >13</option>
<option value="14" <?php if($birday_d==14) echo "selected=\"selected\""; ?> >14</option>
<option value="15" <?php if($birday_d==15) echo "selected=\"selected\""; ?> >15</option>
<option value="16" <?php if($birday_d==16) echo "selected=\"selected\""; ?> >16</option>
<option value="17" <?php if($birday_d==17) echo "selected=\"selected\""; ?> >17</option>
<option value="18" <?php if($birday_d==18) echo "selected=\"selected\""; ?> >18</option>
<option value="19" <?php if($birday_d==19) echo "selected=\"selected\""; ?> >19</option>
<option value="20" <?php if($birday_d==20) echo "selected=\"selected\""; ?> >20</option>
<option value="21" <?php if($birday_d==21) echo "selected=\"selected\""; ?> >21</option>
<option value="22" <?php if($birday_d==22) echo "selected=\"selected\""; ?> >22</option>
<option value="23" <?php if($birday_d==23) echo "selected=\"selected\""; ?> >23</option>
<option value="24" <?php if($birday_d==24) echo "selected=\"selected\""; ?> >24</option>
<option value="25" <?php if($birday_d==25) echo "selected=\"selected\""; ?> >25</option>
<option value="26" <?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="28" <?php if($birday_d==28) echo "selected=\"selected\""; ?> >28</option>
<option value="29" <?php if($birday_d==29) echo "selected=\"selected\""; ?> >29</option>
<option value="30" <?php if($birday_d==30) echo "selected=\"selected\""; ?> >30</option>
<option value="31" <?php if($birday_d==31) echo "selected=\"selected\""; ?> >31</option>
</select>
ÈÕ
</td>
</tr>
<tr>
<td>°®ºÃ</td>
<td> <input type="text" name="hobby" size="44" value=<?php echo $user['hobby'] ?> /></td>
</tr>
<tr>
<td>¸oÈ˼o½e</td>
<td> <textarea name="profile" rows="10" cols="30" ><?php echo $user['profile'] ?> </textarea> </td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="È*¶¨ÐÞ¸Ä" /></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
</form>
</body>
</html>
<?php
require_once 'inc/dbConn.php';
////////////////////
///»ñÈ¡Óû§ÐÅÏ¢
////////////////////
$user_id = $_POST['user_id'];
$user_name = $_POST['user_name'];
$password= $_POST['password'];
if($_POST['sex']=='ÄÐ')
{
$sex=1;
}
else if($_POST['sex']=='Å®')
{
$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(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',hobby='$hobby',profile='$profile' where id='$user_id'";
echo $sql;
// Ö´ÐÐsqlÓi¾a
mysql_query($sql,$con);
// »ñÈ¡Ó°ÏiµÄÐÐÊý
$rows = mysql_affected_rows();
// *µ»ØÓ°ÏiÐÐÊý
// Èç¹uÓ°ÏiÐÐÊý>=1,ÔoÅжÏÌi¼Ó³É¹¦,*ñÔoʧ°Ü
if($rows >= 1)
{
alert("±a¼³É¹¦");
href("userListt.php");
}else{
alert("±a¼Ê§°Ü");
// 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>";
}
?>
<!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>²e¿´Óû§Ã÷ϸ</title>
</head>
<body>
<?php
require_once 'inc/dbConn.php';
$userId=$_GET['id'];
//ÕaÊÇɶ¶«¶«¡£¡£
date_default_timezone_set("PRC");
//¶ÁÊý¾Ý¡£¡£¡£
$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>Óû§ID </td>
<td> <?php echo $userId ?> </td>
</tr>
<tr>
<td>Óû§Ãu </td>
<td> <?php echo $user['username'] ?> </td>
</tr>
<tr>
<td>ÃÜÂe</td>
<td> <?php echo $user['password'] ?> </td>
</tr>
<tr>
<td>ÐÔ±ð</td>
<td> <?php if($user[sex]=='1') echo "ÄÐ"; else if($user[sex]=='2') echo "Å®"; else "±£ÃÜ"; ?>
</td>
</tr>
<tr>
<td>ÄeÁa</td>
<td> <?php echo $user['age'] ?> </td>
</tr>
<tr>
<td>³oÉuÄeÔÂ</td>
<td>
<!-- 1¡£È¡µÃÄeÔÂÈÕ¡£2¡£ÏaÓ¦µÄÄeÔÂÈÕ¡£¡£¡£Äa¶®µÄ -->
<?php
$birday_y=date("Y",$user['birthday']);echo $birday_y."Äe";
$birday_m=date("m",$user['birthday']);echo $birday_m."ÔÂ";
$birday_d=date("d",$user['birthday']);echo $birday_d."ÈÕ";
?>
</td>
</tr>
<tr>
<td>°®ºÃ</td>
<td> <?php echo $user['hobby'] ?> </td>
</tr>
<tr>
<td>¸oÈ˼o½e</td>
<!--Òa¿É¿oÆð <td> <textarea name="profile" rows="10" cols="30" readonly><?php echo $user['profile'] ?> </textarea> </td> -->
<td> <?php echo $user['profile'] ?> </td>
</tr>
<tr>
<td colspan="2" align="center"><a href="userListt.php" >*µ»ØÓû§Áбi</a></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
<?php
// °uº¬Êý¾Ý¿aÎļþ
require_once 'inc/dbConn.php';
// »ñȡɾ³ýµÄid
$id = $_GET['id'];
$row = delete($id,$con);
if($row >=1){
alert("ɾ³ý³É¹¦");
}else{
alert("ɾ³ýʧ°Ü");
}
// Ìøתµ½Óû§ÁбiÒ³Ãae
href("userListt.php");
function delete($id,$con){
$sql = "delete from user where id='$id'";
// Ö´ÐÐɾ³ý
mysql_query($sql,$con);
// »ñÈ¡Ó°ÏiµÄÐÐÊý
$rows = mysql_affected_rows();
// *µ»ØÓ°ÏiÐÐÊý
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>";
}
?>
<!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>ÐÂÔoÓû§</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>Óû§Ãu </td>
<td> <input type="text" name="user_name" size="10" /></td>
</tr>
<tr>
<td>ÃÜÂe</td>
<td> <input type="password" name="password" size="10" /></td>
</tr>
<tr>
<td>ÐÔ±ð</td>
<td> <input type="radio" name="sex" value="ÄÐ" checked="checked" /> ÄÐ<input type="radio" name="sex" value="Å®" /> Å® </td>
</tr>
<tr>
<td>ÄeÁa</td>
<td> <input type="text" name="age" size="3" /></td>
</tr>
<tr>
<td>³oÉuÄeÔÂ</td>
<td>
<select name="birthday_y">
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
</select>
Äe
<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="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
ÔÂ
<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="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
ÈÕ
</td>
</tr>
<tr>
<td>°®ºÃ</td>
<td> <input type="text" name="hobby" size="44" /></td>
</tr>
<tr>
<td>¸oÈ˼o½e</td>
<td> <textarea name="profile" rows="10" cols="30"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Ôo¼ÓÓû§" /></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
</form>
</body>
</html>
<?php
require_once 'inc/dbConn.php';
////////////////////
///»ñÈ¡Óû§ÐÅÏ¢
////////////////////
$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']=='Å®')
{
$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(date("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;
// Ö´ÐÐsqlÓi¾a
mysql_query($sql,$con);
// »ñÈ¡Ó°ÏiµÄÐÐÊý
$rows = mysql_affected_rows();
// *µ»ØÓ°ÏiÐÐÊý
// Èç¹uÓ°ÏiÐÐÊý>=1,ÔoÅжÏÌi¼Ó³É¹¦,*ñÔoʧ°Ü
if($rows >= 1){
alert("Ìi¼Ó³É¹¦");
href("userListt.php");
}else{
alert("Ìi¼Óʧ°Ü");
// 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>";
}
?>
ÒÔÉÏËuÊo¾ÍÊDZ¾ÎĵÄÈ«²¿ÄÚÈÝÁË£¬Ï£Íu´o¼ÒÄܹ»Ï²»¶¡£
ÇeÄu»¨Ò»µaʱ¼a½«ÎÄÕÂ*ÖÏi¸øÄuµÄÅoÓÑ»oÕßÁoÏÂÆÀÂÛ¡£ÎÒÃǽ«»aÓÉÖÔ¸ÐлÄuµÄÖ§³Ö£¡