>php教程 >php手册 >PHP实现通过get方式识别用户发送邮件的方法,get发送邮件

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

WBOY
WBOY원래의
2016-06-13 08:57:48768검색

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

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

send_email.php如下:

<&#63;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('&#63;&#63;&#63;&#63;&#63;&#63;&#63;&#63;&#63;');</script>";
    echo "<script>window.location.href='reg.php'</script>";
  }
&#63;>

reg.php如下:

<&#63;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&#63;id=".$out["id"]."'>查看邮件</a><br/>";
  }
&#63;>

newfile.php如下:

<&#63;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&#63;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&#63;id=".$result_email["id"]."'>您有新邮件</a></strong>";
}
&#63;>

login.php如下:

<&#63;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>";
&#63;>

delete_session.php如下:

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

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

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.