温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用PHP怎么实现一个迷你漂流瓶功能

发布时间:2021-01-25 17:29:09 来源:亿速云 阅读:235 作者:Leah 栏目:开发技术

这期内容当中小编将会给大家带来有关使用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怎么实现一个迷你漂流瓶功能了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI