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

yipeiwu_com5年前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程序设计有所帮助。

相关文章

php过滤html标记属性类用法实例

本文实例讲述了php 过滤html标记属性类及其用法。是PHP项目开发中比较常见的实用技巧。分享给大家供大家参考。具体方法如下: HtmlAttributeFilter.class.ph...

PHP文件读写操作相关函数总结

PHP文件读写操作相关函数总结

一、fwrite()写入文件 将程序中的数据保存到文件中比较容易,使用fwrite()函数就可以将字符串内容写入文件中。在文件中中通过字符序列\n表示换行符,表示文件中一行的末尾。当需要...

PHP判断函数是否被定义的方法

PHP判断函数是否被定义的方法

本教程将介绍判断函数是否被定义 新建一个246.php,如图所示: 输入php网页的结构(<?php?>),如图所示: 声明PHP与浏览器交互的文件类型和...

PHP设计模式之原型模式定义与用法详解

本文实例讲述了PHP设计模式之原型模式定义与用法。分享给大家供大家参考,具体如下: 原型设计模式(Prototype Design Pattern)很有意思, 因为它使用了一种克隆技术来...

判断是否为指定长度内字符串的php函数

复制代码 代码如下: //———————————————————————————– // 函数名:CheckLengthBetween($C_char, $I_len1, $I_len2...