Home  >  Article  >  Backend Development  >  Mini drift bottle implemented in PHP_php skills

Mini drift bottle implemented in PHP_php skills

WBOY
WBOYOriginal
2016-05-16 20:09:511305browse

The example in this article describes the mini drift bottle implemented in PHP. Share it with everyone for your reference. The details are as follows:

mysql.php:

<&#63;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">
<&#63;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)){
&#63;>
 <tr>
  <td class="box" width="12%">ID : </td>
  <td class="box" width="88%"><&#63;=$re['author']&#63;></td>
 </tr>
 <tr>
  <td class="box" >Text : </td>
  <td class="box"><&#63;=$re['text'] &#63;></td>
 </tr>
 <tr>
  <td class="box">Date : </td>
  <td class="box"><&#63;=$re['date']&#63;></td>
 </tr>
 <p class="box">已读标记 <&#63;=$re['flag']&#63;></p>
</table>
<&#63;php
$q = "update `btn` set flag = 1 where id = {$re['id']}";
mysql_query($q);
}
}
&#63;>
<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>
<&#63;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);
  }
}
&#63;>
<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="<&#63;=date('Y-m-d')&#63;>" /></td>
 </tr>
</table>
<div align="center"><input class="btn" name="send" type="submit" value="Send Message"/></div>
</form>
</body>
</html>

I hope this article will be helpful to everyone’s PHP programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn