这篇文章主要介绍了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 ('".$_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>"; ?>
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
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
2 weeks agoByDDD
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.