我正在编写一个针对潜在客户联系表单的脚本,需要将前10个潜在客户发送到电子邮件1,第二个10表示发送电子邮件2,依此类推,直到收到电子邮件4,然后又回到电子邮件1.
这是我为登陆页面制作的旋转器,但它每次旋转1次而不是等待10次,然后旋转。我如何修改它以满足我的需求?
此外,显然每次'刷新'都不会发生这种情况。需要一个单独的代码组,它将放在表单的action =“whatever.php”中,这就是增加它的代码。
<?php
//these are the email addresses to be rotated
$email_address[1] = 'email1@email.com';
$email_address[2] = 'email2@email.com';
$email_address[3] = 'email3@email.com';
$email_address[4] = 'email4@email.com';
//this is the text file, which will be stored in the same directory as this file,
//count.txt needs to be CHMOD to 777, full privileges, to read and write to it.
$myFile = "count.txt";
//open the txt file
$fh = @fopen($myFile, 'r');
$email_number = @fread($fh, 5);
@fclose($fh);
//see which landing page is next in line to be shown.
if ($email_number >= count($email_address)) {
$email_number = 1;
} else {
$email_number = $email_number + 1;
}
//write to the txt file.
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $email_number . "\n";
fwrite($fh, $stringData);
fclose($fh);
//include the landing page
echo $email_address[$email_number];
//terminate script
die();
?>
答案 0 :(得分:1)
我从你的问题中理解的是,会有提交线索的表格,当提交线索时,它必须遵循你的逻辑。如果我错了,请纠正我。
如果是这样的话, 使用两个像track.txt这样的文本文件。该文本文件的初始内容为1,0。这意味着潜在客户将被发送到第一个电子邮件ID 0次。
因此,在表单的动作脚本中包含以下代码。
<?php
$email_address[1] = 'email1@email.com';
$email_address[2] = 'email2@email.com';
$email_address[3] = 'email3@email.com';
$email_address[4] = 'email4@email.com';
$myFile = "track.txt";
//open the txt file
$fh = @fopen($myFile, 'r');
$track = @fread($fh, 5);
@fclose($fh);
$track = explode(",",$track);
$email = $track[0];
$count = $track[1];
if($count >= 10)
{
$count=0;
if($email >= count($email_address))
{
$email = 1;
}
else
{
$email++;
}
}
else
{
$count++;
}
$track = $email.",".$count;
//write to the txt file.
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $track);
fclose($fh);
//send lead to $email
&GT;