PHP实现的迷你漂流瓶

<?php mysql_connect('127.0.0.1','root','wjy123') or die('exit(-1)'); mysql_select_db('floatbtn'); mysql_query('set names utf8');

pickbtn.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>ppick u</title> <style type="text/css"> .btn { font-family: "微软雅黑"; font-size: 12px; color: #FFF; background-color: #369; border: 1px solid #666; } .box { font-family: "微软雅黑"; color: #369; font-size: 12px; border: 1px solid #369; } </style> </head> <body> <a href='https://www.jb51.net/throwbtn.php'>发布信息</a> <form method="post" action="https://www.jb51.net/pickbtn.php"> <table> <?php @include('mysql.php'); if(isset($_REQUEST['new'])){ $q = 'SELECT * FROM `btn`'; $rs = mysql_query($q); $max = mysql_num_rows($rs); $rd = rand(1,$max); $q = "select * from `btn` where id = {$rd}"; $rs = mysql_query($q); while($re = mysql_fetch_array($rs)){ ?> <tr> <td>ID : </td> <td><?=$re['author']?></td> </tr> <tr> <td >Text : </td> <td><?=$re['text'] ?></td> </tr> <tr> <td>Date : </td> <td><?=$re['date']?></td> </tr> <p>已读标记 <?=$re['flag']?></p> </table> <?php $q = "update `btn` set flag = 1 where id = {$re['id']}"; mysql_query($q); } } ?> <input type="submit" value="截取"/> </form> </body> </html>

throwbtn.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>微软雅黑</title> <style type="text/css"> .btn { font-family: "微软雅黑"; font-size: 12px; color: #FFF; background-color: #369; border: 1px solid #666; } .box { font-family: "微软雅黑"; color: #369; font-size: 12px; border: 1px solid #369; } .box1 { font-family: "微软雅黑"; font-size: 12px; color: #369; width: 800px; border: 1px solid #666; } </style> </head> <body> <a href='https://www.jb51.net/pickbtn.php'>截取信息</a> <?php @include('mysql.php'); if(isset($_REQUEST['send'])){ echo 'Publish Successed !<br>'; $author = $_REQUEST['author']; $text = $_REQUEST['text']; $date = date('Y-m-d h:m:s'); if(!(null == trim($author)) && !(null == trim($text))) { $q = "insert into `btn`(`id`,`author`,`text`,`date`,`flag`) values('','$author','$text','$date','0')"; mysql_query($q); } } ?> <form method="post" action="https://www.jb51.net/throwbtn.php"> <table> <tr> <th>ID</th> <td><input type="text" /></td> </tr> <tr> <th >Text</th> <td><input type="text" /></td> </tr> <tr> <th>Date</th> <td> <input type="text" disabled="disabled" value="<?=date('Y-m-d')?>" /></td> </tr> </table> <div><input type="submit" value="Send Message"/></div> </form> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/d9889a947a9a142364b4b0aec7383e56.html