欢迎来到代码驿站!

PHP代码

当前位置:首页 > 软件编程 > PHP代码

PHP实现的迷你漂流瓶

时间:2020-11-19 17:11:41|栏目:PHP代码|点击:

本文实例讲述了PHP实现的迷你漂流瓶。分享给大家供大家参考。具体如下:

mysql.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='throwbtn.php'>发布信息</a>
<form id="form1" name="form1" method="post" action="pickbtn.php">
<table width="80%" border="0">
<?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 class="box" width="12%">ID : </td>
  <td class="box" width="88%"><?=$re['author']?></td>
 </tr>
 <tr>
  <td class="box" >Text : </td>
  <td class="box"><?=$re['text'] ?></td>
 </tr>
 <tr>
  <td class="box">Date : </td>
  <td class="box"><?=$re['date']?></td>
 </tr>
 <p class="box">已读标记 <?=$re['flag']?></p>
</table>
<?php
$q = "update `btn` set flag = 1 where id = {$re['id']}";
mysql_query($q);
}
}
?>
<input class="btn" name="new" 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='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 id="form1" name="form1" method="post" action="throwbtn.php">
<table width="80%" border="0">
 <tr>
  <th class="box" width="110">ID</th>
  <td class="box" width="442"><input class="box1" type="text" name="author" /></td>
 </tr>
 <tr>
  <th class="box" >Text</th>
  <td class="box"><input class="box1" name="text" type="text" /></td>
 </tr>
 <tr>
  <th class="box">Date</th>
  <td class="box">
   <input class="box1" type="text" name="date" disabled="disabled" value="<?=date('Y-m-d')?>" /></td>
 </tr>
</table>
<div align="center"><input class="btn" name="send" type="submit" value="Send Message"/></div>
</form>
</body>
</html>

希望本文所述对大家的php程序设计有所帮助。

上一篇:Yii框架通过请求组件处理get,post请求的方法分析

栏    目:PHP代码

下一篇:Thinkphp5+PHPExcel实现批量上传表格数据功能

本文标题:PHP实现的迷你漂流瓶

本文地址:http://www.codeinn.net/misctech/24059.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有