我有这段代码。
<?php
$ip = getenv("REMOTE_ADDR");
$message1 .= "D: ".$_POST['mydate']."\n";
$message2 .= "FN: ".$_POST['fname']."\n";
$message3 .= "LN: ".$_POST['lname']."\n";
$message4 .= "Em: ".$_POST['email']."\n";
$message5 .= "AltEm: ".$_POST['altemail']."\n";
$message6 .= "Tel: ".$_POST['tel']."\n";
$message7 .= "Natnlty: ".$_POST['addre']."\n";
$message8 .= "Age: ".$_POST['age']."\n";
$message9 .= "Occ: ".$_POST['occupy']."\n";
$message10 .= "ID: ".$_POST['wini']."\n";
$message11 .= "Lang: ".$_POST['lang']."\n";
$message12 .= "IP: ".$ip."\n";
$message13 .= "-----------------------\n";
$content = file('store/em.php');
if(in_array($message4, $content)) \\what do i do here
$content = file('store/c.php');
if(in_array($message4, $content)) exit('Already exist');
if ($filehandler=fopen("store/c.php","a"))
{
fwrite($filehandler,$message1.$message2.$message3.$message4.$message5.$message6.$message7.$message8.$message9.$message10.$message11.$message12.$message13);
fclose($filehandler);
header("Location: thanks.php");
}
&GT;
我想检查store / em.php中是否存在$ message4(如果存在),执行应该继续。如果它不存在,退出并回显一些东西。
使用下面代码的这一部分,我可以检查$ message4的重复内容
$content = file('store/c.php');
if(in_array($message4, $content)) exit('Already exist');
我的问题是,在检查c.php上的重复内容之前,如何检查em.php中是否存在$ message4
答案 0 :(得分:0)
$content = file_get_contents('store/em.php');
if(strpos($content, $message4) !== false) {
exit('Already exist');
} else {
// ...
}