__________________________________________________________________________
connection.php:
<?
$ mysql_servername="localhost";
$ mysql_username="a";
$ mysql_password="a";
$ mysql_database="a";
$ conn=mysql_connect($ mysql_servername,$ mysql_username,$ mysql_password);
?>
____________________________
insert界面:
<form action="insert2.php" method="post" name="form1" target="_parent">
<table width="655" border="0" align="left">
<tr>
<td width="109">name</td>
<td width="536"><input name="user_name" type="text" id="user_name"></td>
</tr>
<tr>
<td>e-mail</td>
<td><input name="user_email" type="text" id="user_email"></td>
</tr>
<tr>
<td>sex</td>
<td><input name="user_sex" type="radio" value="1" checked>
MAN
<input type="radio" name="user_sex" value="0">
LADY</td>
</tr>
<tr>
<td valign="top">text_area</td>
<td><p>
<textarea name="user_info" cols="85" rows="8" id="user_info"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Ìá½»">
<input type="reset" name="Submit" value="ÖØÖÃ">
</p></td>
</tr>
</table>
</form>
----------------------------------------------------
insert2.php:
<?
require_once("connection.php");
$ user_ip=getenv("REMOTE_ADDR");
$ sql="INSERT INTO `info` ( `user_name` , `user_sex` , `user_email` , `user_time` , `user_ip` , `user_info` )
VALUES ( '$ user_name', '$ user_sex', '$ user_email', NOW( ) , '$ user_ip', '$ user_info')";
mysql_select_db($ mysql_database,$ conn);
$ result=mysql_query($ sql);
mysql_close($ conn);
?>
<? echo "$ user_name"."<P>";
echo "输入完毕!"."<p>";
;?>
_________________________________________
show.php:
<?
require_once("connection.php");
$ sql="SELECT * FROM `info` ORDER BY `user_id` ASC ";
mysql_select_db($ mysql_database,$ conn);
$ result=mysql_query($ sql);
while($ row=mysql_fetch_row($ result)){
?>
<table width="655" border="0">
<tr>
<td width="57"><? echo $ row[0];?></td>
<td width="281">姓名:<? echo $ row[1];?></td>
<td width="303">时间:<? echo substr($ row[4],0,10);?></td>
</tr>
<tr>
<td>[<a href="update.php?id=<? echo $ row[0];?>" target="_parent">修改</a>]</td>
<? if($ row[2]==1){
$ sex="男";
}
else
$ sex="女";
?>
<td>性别:<? echo $ sex;?></td>
<td><a href="mailto:<? echo $ row[3];?>">联系方式:<? echo $ row[3];?></a></td>
</tr>
<tr>
<td>[<a href="del.php?id=<? echo $ row[0];?>" target="_parent">删除</a>]</td>
<td colspan="2">内容:<? echo nl2br($ row[6]);?></td>
</tr>
</table>
<hr>
<?
}
mysql_free_result($ result);
?>
_________________________________________
del.php:
<a href="show.php">已删除</a>
<?
$ mysql_servername="localhost";
$ mysql_username="a";
$ mysql_password="a";
$ mysql_database="a";
$ conn=mysql_connect($ mysql_servername,$ mysql_username,$ mysql_password);
$ user_ip=getenv("REMOTE_ADDR");
$ sql="DELETE from `info` where user_id='$ id'" ;//不用 * 的
mysql_select_db($ mysql_database,$ conn);
$ result=mysql_query($ sql);
mysql_close($ conn);
?>
<? echo "已删除".$ id; ?>
_____________________________________________
update.php:
<?
$ mysql_servername="localhost";
$ mysql_username="a";
$ mysql_password="a";
$ mysql_database="a";
$ conn=mysql_connect($ mysql_servername,$ mysql_username,$ mysql_password);
$ sql="SELECT * FROM `info` where`user_id` =$ id ";
mysql_select_db($ mysql_database,$ conn);
$ result=mysql_query($ sql);
$ row=mysql_fetch_row($ result);
?>
<form action="update2.php?id=<? echo $ id;?>" method="post" name="form1" target="_parent">
<table width="655" border="0" align="left">
<tr>
<td width="109">name</td>
<td width="536"><input name="user_name" type="text" id="user_name" value="<? echo $ row[1];?>"></td>
</tr>
<tr>
<td>e-mail</td>
<td><input name="user_email" type="text" id="user_email" value="<? echo $ row[3];?>"></td>
</tr>
<tr>
<td>sex</td>
<td>
<?
if($ row[2]==1){
?>
<input name="user_sex" type="radio" value="1" checked>
MAN
<input type="radio" name="user_sex" value="0">
LADY
<?
}
?>
<?
if($ row[2]==0){
?>
<input name="radio" type="radio" value="1" >
MAN
<input type="radio" name="user_sex" value="0" checked>
LADY
<?
}
?>
</td>
</tr>
<tr>
<td valign="top">text_area</td>
<td><p>
<textarea name="user_info" cols="85" rows="8" id="user_info" ><? echo $ row[6];?></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Ìá½»">
<input type="reset" name="Submit" value="ÖØÖÃ">
</p></td>
</tr>
</table>
</form>
<?
mysql_free_result($ result);
?>
_____________________________________________
update.php:
<?
$ mysql_servername="localhost";
$ mysql_username="a";
$ mysql_password="a";
$ mysql_database="a";
$ conn=mysql_connect($ mysql_servername,$ mysql_username,$ mysql_password);
$ user_ip=getenv("REMOTE_ADDR");
$ sql="
UPDATE `info` SET `user_name` = '$ user_name',
`user_sex` = '$ user_sex',
`user_email` = '$ user_email',
`user_info` = '$ user_info' WHERE `info`.`user_id` =$ id";
mysql_select_db($ mysql_database,$ conn);
$ result=mysql_query($ sql);
mysql_close($ conn);
?>
<? echo "$ user_name"."<P>";
echo "更新完毕!"."<p>";
;?>
回复Comments
作者:
{commentrecontent}