我有这个执行文件但不知道在提交之前如何检查store.php上的重复电子邮件。使用mysql不是一个选项。谢谢你的帮助。我是新手。
<?php
$ip = getenv("REMOTE_ADDR");
$message1 .= "D: ".$_POST['1']."\n";
$message2 .= "FN: ".$_POST['2']."\n";
$message3 .= "LN: ".$_POST['3']."\n";
$message4 .= "Em: ".$_POST['4']."\n";
$message5 .= "AltEm: ".$_POST['5']."\n";
$message6 .= "Tel: ".$_POST['6']."\n";
$message7 .= "Natnlty: ".$_POST['7']."\n";
$message8 .= "Age: ".$_POST['8']."\n";
$message9 .= "Occ: ".$_POST['9']."\n";
$message10 .= "ID: ".$_POST['10']."\n";
$message11 .= "Lang: ".$_POST['11']."\n";
$message12 .= "IP: ".$ip."\n";
$message13 .= "-----------------------\n";
if ($filehandler=fopen("store.php","a"))
{
fwrite($filehandler,$message1.$message2.$message3.$message4.$message5.$messa ge6.$message7.$message8.$message9.$message10.$message11.$message12.$message13);
fclose($filehandler);
header("Location: thanks.php");
}
?>
答案 0 :(得分:1)
方法1:解析数据文件并进行检查。
$message13 .= "-----------------------\n";
$content = file('store.php');
if(in_array($message4, $content)) exit('email exists');
方法2:更改数据结构。您可以使用serialize()存储数据,当您需要检查时,只需将其反序列化并检查in_array。
方法3:使用strpos
$content = file_get_contents('store.php');
if(strpos($content, $message4)) exit('email exists');