PHP实现通过get方式识别用户发送邮件的方法

yipeiwu_com6年前PHP代码库

本文实例讲述了PHP实现通过get方式识别用户发送邮件的方法。分享给大家供大家参考。具体如下:

send_email.php如下:

<?php
  $conn=mysql_connect("localhost","root","admin");
  mysql_select_db("songyunb_development",$conn);
  $id=$_GET["id"];
  $sql="insert into email (sender_id,accepter_id,flag) values ('".$_SESSION["id"]."','".$id."','no')";
  $query=mysql_query($sql);
  if($query)
  {
    echo "<script>alert('?????????');</script>";
    echo "<script>window.location.href='reg.php'</script>";
  }
?>

reg.php如下:

<?php
  $conn=mysql_connect("localhost","root","admin");
  mysql_select_db("songyunb_development",$conn);
  $sql="select * from comments";
  $query=mysql_query($sql);
  while($out=mysql_fetch_array($query))
  {
    echo $out["content"]."-------<a href='newfile.php?id=".$out["id"]."'>查看邮件</a><br/>";
  }
?>

newfile.php如下:

<?php
 $conn=mysql_connect("localhost","root","admin");
  mysql_select_db("songyunb_development",$conn);
 $result="";
 $id="";
 if(isset($_GET["id"]))
 {
  $id=$_GET["id"];
  $sql="select * from comments where id='".$_GET["id"]."'";
  $result=mysql_query($sql);
 }
$out=mysql_fetch_array($result);
echo $out["content"]."<br/>";
echo $out["created_at"]."<br/>";
echo "<a href='send_email.php?id=".$out["id"]."'>发送邮件</a><br/><hr>";
//看看有没有新邮件
$sql_search_email="select * from email where accepter_id='".$id."'";
$query=mysql_query($sql_search_email);
$result_email=mysql_fetch_array($query);
if($result_email["accepter_id"]==$_SESSION["id"]&&$result_email["flag"]=="no")
{
  echo "<strong><a href='see_email.php?id=".$result_email["id"]."'>您有新邮件</a></strong>";
}
?>

login.php如下:

<?php
$conn=mysql_connect("localhost","root","admin");
  mysql_select_db("songyunb_development",$conn);
  $_SESSION["id"]=15;
  echo "<a href='delete_session.php'>清除session</a>";
  echo "<a href='reg.php'>重新注册</a>";
?>

delete_session.php如下:

<?php
  if(isset($_SESSION["id"]))
  {
   unset($_SESSION["id"]);
  }
  echo "<script>alert('清除成功');</script>";
?>

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

相关文章

WordPress中查询文章的循环Loop结构及用法分析

WordPress 上获取文章最重要的就是循环(Loop),事实上循环就是去数据库查询到相应的文章,然后暂时储存到全局变量里边,需要的时候一篇一篇的输出出来,WordPress 的循环设...

PHP技术开发技巧分享

1. 提高PHP的运行效率   PHP的优点之一是速度很快,对于一般的网站应用,可以说是已经足够了。不过如果站点的访问量很高、带宽窄或者其它的因素令服务器产生性能瓶颈的时候,你可能得想想...

php中$_SERVER[PHP_SELF] 和 $_SERVER[SCRIPT_NAME]之间的区别

“PHP_SELF” 当前正在执行脚本的文件名,与 document root 相关。举例来说,在 URL 地址为 //www.jb51.net/test.php/foo.bar 的脚本...

解析Linux下Varnish缓存的配置优化

Varnish是一款高性能的开源HTTP加速器,挪威最大的在线报纸 Verdens Gang 使用3台Varnish代替了原来的12台Squid,性能比以前更好。但与老牌的squid相比...

必须收藏的23个php实用代码片段

在编写代码的时候有个神奇的工具总是好的!下面这里收集了 40+ PHP 代码片段,可以帮助你开发 PHP 项目。 这些 PHP 片段对于 PHP 初学者也非常有帮助,非常容易学习,让我...