这篇文章主要介绍了PHP实现通过get方式识别用户发送邮件的方法,涉及php针对数据库的读取、判断及session登陆的使用技巧,需要的朋友可以参考下
本文实例讲述了PHP实现通过get方式识别用户发送邮件的方法。分享给大家供大家参考。具体如下:
send_email.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 "";
echo "";
}
?>
reg.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"]."-------查看邮件
";
}
?>
newfile.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"]."
";
echo $out["created_at"]."
";
echo "发送邮件
";
//看看有没有新邮件
$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 "您有新邮件";
}
?>
login.php如下:
$conn=mysql_connect("localhost","root","admin");
mysql_select_db("songyunb_development",$conn);
$_SESSION["id"]=15;
echo "清除session";
echo "重新注册";
?>
delete_session.php如下:
if(isset($_SESSION["id"]))
{
unset($_SESSION["id"]);
}
echo "";
?>
希望本文所述对大家的php程序设计有所帮助。