高手!!高手!!请进来看一下!!有关复杂邮件的一个功能!!!
折腾一周没做出来的一个东东,今天周末加班还是没有战果,初次接触程序啊,还望高手多多指点!!!!在此先谢过!!!
需求:
做一个合同模块,分多段提醒,我现在只做了两段提醒。
即:
只要检测到sdate,edate 有与当前系统时间(2008-7-19)时间相同的都得那行邮件地址发送一份邮件.
数据库设置:
sdate edate email name
2008-7-11 2008-7-19 adfd@aa.com adfd
2008-7-15 2008-7-19 bbcc@aa.com bbcc
2008-7-19 2008-7-22 xxbb@aa.com xxbb
2008-7-19 2008-7-28 ccbb@aa.com ccbb
基本实现思路:
我现在用了一个phpmailer的类来做。(环境是:linux+apache+php+mysql)
写了一个cron.php的文件(如下:),用crontab每天刷新一次cron.php页面
判断当当前系统时间与2008-7-19一致,如果是一致就发邮件
照上面数据的数据,检测到sdate有二条2008-7-19,edate有二条2008-7-19,就得发四个邮件提醒这四个用户。
现在我的程序出现问题: 就是每次只会去取其中一条记录,而且只会对这一条记录发邮件,而其它三条相同的时间,就没办法达到提醒功能;
非常急切,请大家帮忙!!!非常感谢感谢!!
//cron.php的文件如下:
date_default_timezone_set('Asia/Shanghai');
$datesy=date("Y-m-d"); //当前系统时间
//$format="
$db=mysql_connect('localhost','root','');
mysql_select_db('test',$db);
$sql="select sdate,edate,email,name from testmail"; //sdate 与edate字段分别对应数据库中的两段时间
mysql_query("set names gb2312");
$result=mysql_query($sql,$db);
while ($row = mysql_fetch_array($result))
{
printf ($format,$row[0],$row[1],$row[2],$row[3],$row[4],$row[5]);
if($datesy==$row[0] || datesy==$row[1]) //目前是:如果定点刷新页面,程序只会去检测$row[1] 也就是edate时间,只会取一个而发送邮件,如果edate有2条或更多为2008--7-19的时间,都不会发邮件。我的目的是要:如果sdate ,date 哪怕是一百行数据,只要是与当前时间一致,都要发邮件。
{
require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$address=$row[1];
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.aaa.com.cn"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "Josh"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->From = "Josh@aaa.com.cn";
$mail->FromName = "Mailer";
$mail->AddAddress("$address", "Josh Adams");
$mail->AddAddress("xx@bbb.com.cn"); // name is optional
$mail->AddReplyTo("xx@bbb.com.cn", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$name="$row[2]";
$mail->Subject ="$name 到期了";
$mail->Body = "This is the HTML message body in bold!";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent.
";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
}
// }
else
{
echo "不成功";
}
}
mysql_close();
?>
------解决方案--------------------
关键是$address=$row[1];
错了
------解决方案--------------------

PHPsessionscanstorestrings,numbers,arrays,andobjects.1.Strings:textdatalikeusernames.2.Numbers:integersorfloatsforcounters.3.Arrays:listslikeshoppingcarts.4.Objects:complexstructuresthatareserialized.

TostartaPHPsession,usesession_start()atthescript'sbeginning.1)Placeitbeforeanyoutputtosetthesessioncookie.2)Usesessionsforuserdatalikeloginstatusorshoppingcarts.3)RegeneratesessionIDstopreventfixationattacks.4)Considerusingadatabaseforsessionstoragei

Session regeneration refers to generating a new session ID and invalidating the old ID when the user performs sensitive operations in case of session fixed attacks. The implementation steps include: 1. Detect sensitive operations, 2. Generate new session ID, 3. Destroy old session ID, 4. Update user-side session information.

PHP sessions have a significant impact on application performance. Optimization methods include: 1. Use a database to store session data to improve response speed; 2. Reduce the use of session data and only store necessary information; 3. Use a non-blocking session processor to improve concurrency capabilities; 4. Adjust the session expiration time to balance user experience and server burden; 5. Use persistent sessions to reduce the number of data read and write times.

PHPsessionsareserver-side,whilecookiesareclient-side.1)Sessionsstoredataontheserver,aremoresecure,andhandlelargerdata.2)Cookiesstoredataontheclient,arelesssecure,andlimitedinsize.Usesessionsforsensitivedataandcookiesfornon-sensitive,client-sidedata.

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools
