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

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

PHP中文网
PHP中文网Original
2016-05-25 17:13:21950Durchsuche

这篇文章主要介绍了PHP实现通过get方式识别用户发送邮件的方法,涉及php针对数据库的读取、判断及session登陆的使用技巧,需要的朋友可以参考下

本文实例讲述了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 (&#39;".$_SESSION["id"]."&#39;,&#39;".$id."&#39;,&#39;no&#39;)";
  $query=mysql_query($sql);
  if($query)
  {
    echo "<script>alert(&#39;?????????&#39;);</script>";
    echo "<script>window.location.href=&#39;reg.php&#39;</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=&#39;newfile.php?id=".$out["id"]."&#39;>查看邮件</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=&#39;".$_GET["id"]."&#39;";
  $result=mysql_query($sql);
 }
$out=mysql_fetch_array($result);
echo $out["content"]."<br/>";
echo $out["created_at"]."<br/>";
echo "<a href=&#39;send_email.php?id=".$out["id"]."&#39;>发送邮件</a><br/><hr>";
//看看有没有新邮件
$sql_search_email="select * from email where accepter_id=&#39;".$id."&#39;";
$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=&#39;see_email.php?id=".$result_email["id"]."&#39;>您有新邮件</a></strong>";
}
?>

login.php如下:

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

delete_session.php如下:

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php网址转换为超链接方法 Nächster Artikel:php里Array2xml