作者 主題: [求助]如何於資料表中的到期日到時寄出一封信至該用戶信箱?  (閱讀 7104 次)

0 會員 與 1 訪客 正在閱讀本文。

netdoit

  • 可愛的小學生
  • *
  • 文章數: 18
    • 檢視個人資料
各位大大請教一個問題:
目前我有做一個客戶資料管理程式,而在這支程式的資料表中我有規劃了用戶的信箱(email)租書到期日(booklimdate)與租片到期日(videolimdate),我想要讓租書到期日與租片到期日前30/15/7/3/1天寄出一封到期通知信給用戶的信箱,【內容比如說:敬愛的顧客xx您好!您向本店租賃的書籍將於$booklimdate到期,敬請注意還書日期,謝謝!! 】請問我該怎麼做呢?

以下是我目前寫的程式:敬請大大不吝惠予協助~感激不盡
代碼: [選擇]
//*************************************************   bookstore_edit   *********************************************************

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "bookstore_edit")) {



 $updateSQL = sprintf("UPDATE bookstore SET name=%s, tel=%s, fax=%s, city=%s, adr=%s, email=%s,  mobile=%s,  bookdate=%s, booklimdate=%s, videodate=%s,videolimdate=%s,  flag=%s WHERE id=%s",
            GetSQLValueString($_POST['company'], "text"),
GetSQLValueString($_POST['tel'], "text"),
GetSQLValueString($_POST['fax'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['adr'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['mobile'], "text"),
GetSQLValueString($_POST['bookdate'], "text"),
        GetSQLValueString($_POST['booklimdate'], "text"),
                                            GetSQLValueString($_POST['videodate'], "text"),
                    GetSQLValueString($_POST['videolimdate'], "text"),
                    GetSQLValueString($_POST['flag'], "int"),
                       GetSQLValueString($_POST['id'], "int"));
  mysql_select_db($database_connect, $connect);

  $Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());

 

  echo "<script>";

  echo "alert(\"資料更新成功!!\");";

  echo "location.href='bookstore_list.php'";

  echo "</script>";

}

Yamaka

  • 俺是博士!
  • *****
  • 文章數: 4913
    • 檢視個人資料
    • http://www.ecmagic.com
各位大大請教一個問題:
目前我有做一個客戶資料管理程式,而在這支程式的資料表中我有規劃了用戶的信箱(email)租書到期日(booklimdate)與租片到期日(videolimdate),我想要讓租書到期日與租片到期日前30/15/7/3/1天寄出一封到期通知信給用戶的信箱,【內容比如說:敬愛的顧客xx您好!您向本店租賃的書籍將於$booklimdate到期,敬請注意還書日期,謝謝!! 】請問我該怎麼做呢?

以下是我目前寫的程式:敬請大大不吝惠予協助~感激不盡
代碼: [選擇]
//*************************************************   bookstore_edit   *********************************************************

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "bookstore_edit")) {



 $updateSQL = sprintf("UPDATE bookstore SET name=%s, tel=%s, fax=%s, city=%s, adr=%s, email=%s,  mobile=%s,  bookdate=%s, booklimdate=%s, videodate=%s,videolimdate=%s,  flag=%s WHERE id=%s",
            GetSQLValueString($_POST['company'], "text"),
GetSQLValueString($_POST['tel'], "text"),
GetSQLValueString($_POST['fax'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['adr'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['mobile'], "text"),
GetSQLValueString($_POST['bookdate'], "text"),
        GetSQLValueString($_POST['booklimdate'], "text"),
                                            GetSQLValueString($_POST['videodate'], "text"),
                    GetSQLValueString($_POST['videolimdate'], "text"),
                    GetSQLValueString($_POST['flag'], "int"),
                       GetSQLValueString($_POST['id'], "int"));
  mysql_select_db($database_connect, $connect);

  $Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());

 

  echo "<script>";

  echo "alert(\"資料更新成功!!\");";

  echo "location.href='bookstore_list.php'";

  echo "</script>";

}

寄信喔~ 用 mail() 嘍~

http://tw2.php.net/manual/en/function.mail.php

netdoit

  • 可愛的小學生
  • *
  • 文章數: 18
    • 檢視個人資料
嗯~我知道用mail
只是這些條件的邏輯
租書到期日與租片到期日前30/15/7/3/1天寄出一封到期通知信給用戶的信箱,【內容比如說:敬愛的顧客xx您好!您向本店租賃的書籍將於$booklimdate到期,敬請注意還書日期,謝謝!! 】請問我該怎麼做呢?我不懂應該怎樣設定
目前我只會寫到這裡就卡住了!@@"
代碼: [選擇]
//get the sender mail

mysql_select_db($database_connect, $connect);

$query_RecMail = "SELECT send FROM mail";

$RecMail = mysql_query($query_RecMail, $connect) or die(mysql_error());

$row_RecMail = mysql_fetch_assoc($RecMail);

  

$name=iconv("UTF-8","Big5",$_POST["name"]);

$se_content=iconv("UTF-8","Big5",$_POST["se_content"]);

$subject=iconv("UTF-8","Big5",$_POST["subject"]);  

  

// message

$to = $_POST['mailto'];

$message  = "敬愛的顧客 " .$name." 您好:\n";

$message .= $se_content."\n";

$message .= " 您向本店租賃的書籍將於$booklimdate到期,敬請注意還書日期,謝謝!!謝謝您!\n";

$headers .= 'From: ' .$row_RecMail['send']. "(客服中心)\r\n" .

'X-Mailer: PHP/' . phpversion();



// Set internal character encoding to UTF-8

mb_internal_encoding("big5");

$result = mb_send_mail($to, $subject, $message, $headers);

  

  echo "<script>";

  echo "alert(\"寄件成功!!\");";

  echo "location.href='bookstore_list.php'";

  echo "</script>";



}
« 上次編輯: 2009-11-10 09:50 由 netdoit »

Darkhero

  • 酷!學園 學長們
  • 俺是博士!
  • *****
  • 文章數: 3728
  • 性別: 男
    • 檢視個人資料
    • ㄚ凱隨手紀
當天日期 + 30,15,7,3,1 然後去資料庫撈..
撈出來的就是要寄信的了...
希望我們的討論是為了把問題解決,而不是爭論誰對誰錯.
『灌水才是重點,發文只是順便』
『我寧可讓不會釣魚的工程師餓死,也不想讓會餓死的工程師去攪沉公司....』
Blog: http://blog.darkhero.net/
秘密基地: http://www.darkhero.net/comic/
目前服務的網站: http://www.libook.com.tw/

YOGO

  • 可愛的小學生
  • *
  • 文章數: 14
    • 檢視個人資料
    • http://www.jiuher.com.tw/room/
依你的需求寫了一篇小教學,希望能對你有所幫助

Mysql的日期加減運算
http://blog.yogo.tw/2009/11/mysql.html

PHP的日期加減運算
http://blog.yogo.tw/2009/11/php.html



歡迎光臨YOGO生活誌 http://blog.yogo.tw
« 上次編輯: 2009-11-16 15:16 由 YOGO »

netdoit

  • 可愛的小學生
  • *
  • 文章數: 18
    • 檢視個人資料
感謝大大~我有去看了尚在突破中!!我會加油!!!