search
Homephp教程PHP源码PHP实现通过get方式识别用户发送邮件的方法

这篇文章主要介绍了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>";
?>

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor