综合

img bjf_php

留言本

发表于2004/10/25 15:17:00  563人阅读

分类: php程序

guest.php


<?
//如果选择了提交按钮的时候执行

if($submit){

//连接服务器并选择数据库

DBconnect();

//连接成功后插入数据到表中

$query="insert into guests";

$query.="(guest_id,guest_name,guest_email,guest_time,guest_message)";

$query.="values(0000,'$name','$email',NULL,'$message')";

$sql=mysql_query($query);

echo"insert into database success.";

}

//

else{

?>

<form name="form1" method="post" action="guest.php">

<p>请留意见</p>

<p>姓名   
<input name="name" type="text" id="name" >

</p>
<p>Email地址 

<input name="email" type="text" id="email" >

</p>

<p>留言内容</p>

<p>

<textarea name="message" cols="40" rows="10" id="message">

</textarea>

</p>

<input type="submit" name="submit" value="提交" id="submit">

<p>  </p>

</form>

<?

}

?>

<? 

DBconnect();

$numguests=mysql_query("select count(*) from guests ");

$numguest=mysql_fetch_array($numguests);?>

<p><a href="guest.php?complete=1"><? echo $numguest[0];?>个客户</a>留下墨宝


<?
$query="select * from guests order by guest_time desc";

$numguests=mysql_query($query);

while($guest=mysql_fetch_array($numguests)){

?>

</p>


<table width="100%" border="1" cellspacing="1" cellpadding="2">

<tr>

<td>姓名:<? echo $guest["guest_name"];?></td>

<td>email:<? echo $guest["guest_email"];?></td>

<td>


<?
 
$datefromdb=$guest["guest_time"];

$year=substr($datefromdb,0,4);

$mon=substr($datefromdb,4,2);

$day=substr($datefromdb,6,2);

$hour=substr($datefromdb,8,2);

$min=substr($datefromdb,10,2);

$sec=substr($datefromdb,12,2);

$orgdate=date("1FdS,Y h:i A",mktime($hour,$min,$sec,$mon,$day,$year));

echo"时间:$orgdate/n";

?>

</td>

</tr>

<tr>

<td colspan="3"><? echo $guest["guest_message"];?></td>

</tr>

</table>

<?

}

?>



代码演示:
http://www.move2rent.com/site/rent1...mple4/guest.php

阅读全文
0 0

相关文章推荐

img
取 消
img