[PHP_EMAIL] รบกวนดูซอซที่ครับแบบว่ามันไม่ส่งเข้าเมลล์สักที ไม่รู้ผิดตรงไหน
Code (PHP)
<?
include("../lib/utility.php");
connect_db();
// Check Pre Input
if (!isset($_REQUEST["username"])
|| !isset($_REQUEST["password"])
|| !isset($_REQUEST["confirm"])
|| !isset($_REQUEST["name"])
|| !isset($_REQUEST["surname"])
|| !isset($_REQUEST["email"])
|| !isset($_REQUEST["gender"])
|| !isset($_REQUEST["address"])
|| !isset($_REQUEST["country"])
|| !isset($_REQUEST["day"])
|| !isset($_REQUEST["month"])
|| !isset($_REQUEST["year"])) {
header("location:register_form.php");
return;
}
// Prepare Variables
$username = $_REQUEST["username"];
$password = sha1($_REQUEST["password"]);
$confirm = sha1($_REQUEST["confirm"]);
$name = $_REQUEST["name"];
$surname = $_REQUEST["surname"];
$email = $_REQUEST["email"];
$gender = $_REQUEST["gender"];
$address = nl2br($_REQUEST["address"]);
$country = $_REQUEST["country"];
$bday = $_REQUEST["day"];
$bmonth = $_REQUEST["month"];
$byear = $_REQUEST["year"];
$birthday = "$byear-$bmonth-$bday";
if (isset($_REQUEST["interest"])) {
$interest = implode(", ", $_REQUEST["interest"]);
}
else {
$interest = "";
}
$code = random_password();
// Check Post Input
$error = "";
// Username 1
if ($username == "") {
$error .= "äÁèÁÕª×èͼÙéãªé<br />";
}
// Username 2
$sql = "SELECT COUNT(*) FROM member WHERE username='$username'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$num_user = $row["COUNT(*)"];
if ($num_user != 0) {
$error .= "ª×èͼÙéãªé«éÓ<br />";
}
// Password
if ($password != $confirm) {
$error .= "Â×¹ÂѹÃËÑʼèÒ¹äÁèµÃ§¡ÑºÃËÑʼèÒ¹<br />";
}
// E-mail 1
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
$error .= "ÃٻẺÍÕàÁżԴ<br />";
}
// E-mail 2
$sql = "SELECT COUNT(*) FROM member WHERE email='$email'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$num_user = $row["COUNT(*)"];
if ($num_user != 0) {
$error .= "ÍÕàÁÅ«éÓ<br />";
}
// Birthday
if (!checkdate($bmonth, $bday, $byear)) {
$error .= "Çѹà¡Ô´äÁèÁÕÍÂÙè¨ÃÔ§<br />";
}
// Action
if ($error == "") {
// Add New Member
$sql = "INSERT INTO member"
. " (username, password, name, surname, email, gender, address, country, birthday, interest, code, `create`)"
. " VALUES('$username', '$password', '$name', '$surname', '$email', '$gender', '$address', '$country', '$birthday', '$interest', '$code', CURDATE())";
mysql_query($sql) or die(mysql_error());
// Send E-mail
send_mail("webmaster@localhost",
$email,
"New Account from localhost",
"Congratulation, now you are a new member of localhost.<br />Please click <a href='http://localhost/php_e_commerce/member/activate.php?username=$username&code=$code' target='_blank'>here</a> to activate your account.");
// Delete Unactivated Account
$sql = "DELETE FROM member WHERE code<>'' AND DATEDIFF(CURDATE(), `create`) > 3";
mysql_query($sql) or die(mysql_error());
}
// Show Result
if ($error == "") {
$result = "ŧ·ÐàºÕ¹¼Ùéãªé¤¹ãËÁèàÃÕºÃéÍÂ<br />"
. "<a href='login_form.php'>ŧª×èÍà¢éÒãªé</a>";
}
else {
$result = $error
. "<a href='#' onclick='history.back(); return false;'>¡ÅѺä»</a>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ÃкºÊÁÒªÔ¡ - ŧ·ÐàºÕ¹¼Ùéãªé</title>
</head>
<body>
<?=$result?>
</body>
</html>
Tag : PHP, MySQL, Ajax
Date :
2011-05-20 20:43:19
By :
shiowa
View :
1271
Reply :
12
output มันขึ้นแบบนี้อ่าครับ
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\AppServ\www\code\root\lib\utility.php on line 69
กรุณาตรวจสอบรหัสผ่านใหม่ของคุณทางอีเมล
ประวัติการแก้ไข 2011-05-20 21:13:19
Date :
2011-05-20 21:03:19
By :
shiowa
อันนี้เปนไฟลล์ที่เกี่ยวข้อง คับ include ชื่อว่าutility.php
Code (PHP)
<?
function connect_db() {
$host = "localhost";
$username = "xxxx";
$password = "xxxx";
$db = "xxxxx";
@mysql_connect($host, $username, $password) or die("MySQL Connection Failed");
@mysql_select_db($db) or die("MySQL Select Database Failed");
mysql_query("SET NAMES utf8") or die(mysql_error());
}
function random_password() {
$text = "abcdefghijklmnopqrstuvwxyz0123456789";
return substr(str_shuffle($text), 0, 7);
}
function send_mail($from, $to, $subject, $body, $cc = "", $bcc = "", $attach = "") {
// To
$sto = $to;
// Subject
$ssubject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
// Body & Header
// Body, Type
if ($attach == "" || $attach["size"] == 0) {
$sbody = stripslashes($body);
$sheader = "MIME-Version: 1.0\n"
. "Content-type: text/html; charset=utf-8\n";
}
else {
$type = $attach["type"];
$name = $attach["name"];
$size = $attach["size"];
$tname = $attach["tmp_name"];
$file = fopen($tname, "r");
$data = fread($file, $size);
$data = chunk_split(base64_encode($data . "\n"));
fclose($file);
$boundary = uniqid("");
$sbody = "--$boundary\n"
. "Content-type: text/html; charset=utf-8;\n"
. "Content-transfer-encoding: 16bit\n\n"
. stripslashes($body) . "\n"
. "--$boundary\n"
. "Content-type: $type; name=$name\n"
. "Content-transfer-encoding: base64\n\n"
. $data
. "--$boundary--";
$sheader = "MIME-Version: 1.0\n"
. "Content-type: multipart/mixed; boundary=\"$boundary\"\n";
}
// From, CC, BCC
$sheader .= "From: $from";
if ($cc != "") {
$sheader .= "\nCc: $cc";
}
if ($bcc != "") {
$sheader .= "\nBcc: $bcc";
}
return mail($sto, $ssubject, $sbody, $sheader);
}
function check_login($name, $dest) {
if (!isset($_SESSION[$name])) {
header("location:$dest");
return;
}
}
?>
Date :
2011-05-20 21:12:08
By :
shiowa
สงสัยจะรันในเครื่องตัวเอง
Date :
2011-05-20 22:21:52
By :
Dragons_first
ของผมเปนเซเว่น เลยทามตามนี้
http://www.itithai.com/article-tips/windows/258-how-to-install-iis-on-windows-7-or-windows-vista.html
แต่ก็ยังไม่ได้อ่าครับ เฮีย
Date :
2011-05-20 23:23:49
By :
shiowa
ไม่ทราบว่ามัน error ตรงไหนอีกครับ
Date :
2011-05-20 23:41:16
By :
prach_kp
output มันขึ้นแบบนี้อ่าครับ
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\AppServ\www\code\root\lib\utility.php on line 69
กรุณาตรวจสอบรหัสผ่านใหม่ของคุณทางอีเมล
Date :
2011-05-20 23:55:44
By :
shiowa
อาจเปนกับผมรันบนappserve รึป่าวคับ เดานะ
Date :
2011-05-20 23:58:39
By :
shiowa
ทำหลายวิธีและครับ แต่ไม่ว่าจะทำแบบไหนก็แป๊ก แต่ลองขึ้นโฮสจริงไม่ติดerorไหนเลย ยังไงก็ขอบคุณทุกคนหลายๆคับ
Date :
2011-05-22 10:00:42
By :
shiowa
Load balance : Server 03