|
|
|
PHP รบกวนสอบถามปัญหา Formการ ส่งอีเมล์ ลองในเครื่องได้หมดพอ อัพลงserver กลับไม่ได้ |
|
|
|
|
|
|
|
รบกวนช่วยดูให้หน่อยครับ ผมลองใช้ ทำ form ขึ้นมาให้ส่งเมล์ ได้ ลองในเครื่อง (localhost) แล้วผ่านไปได้ด้วยดี มีอีเมล์ที่เราต้องมา inbox แต่พออัพ โค้ดลง server กลับส่งไม่ได้ และมันก็ไม่เปลี่ยนหน้าด้วยครับ ไม่มี error ขึ้น แต่กลับเป็นหน้าเติมก่อนที่จะกรอกข้อความ
Code (PHP)
<? include("booking/dati/dati_connessione.php");
$ann = date("Y");
$conn = mysql_connect($PHPR_DB_HOST,$PHPR_DB_USER,$PHPR_DB_PASS);
if (!$conn) die ("No Connect My SQL");
mysql_select_db($PHPR_DB_NAME) or die ("No Connect".$PHPR_DB_NAME); function redirect($url, $time = 0) {
$str = "<script language=\"javascript\">\n";
$str .= "<!--\n";
if ($time > 0) $str .= "setTimeout(\"redir()\", $time);\n";
else $str .= "redir();\n";
$str .= "function redir() {\n";
$str .= "location.href = '".$url."';\n";
$str .= "}\n";
$str .= "//-->\n";
$str .= "</script>\n";
return $str;
}
require("PHPMailer_v5.1/class.phpmailer.php");
function smtpmail( $email, $subject , $body )
{
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = "utf-8";
$mail->Host = "mail.lilawalai.com";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "*************";
$mail->From = "[email protected]";
$mail->FromName = "weblilawalai";
//$mail->AddAddress($email2);
$mail->AddAddress($email);
$mail->IsHTML(false);
$mail->Subject = $subject;
$mail->Body = $body;
$result = $mail->send();
return $result;
}
if ($REQUEST_METHOD == "GET") {
$email2 = "[email protected]";
$to = stripslashes($email2);
$subject =" Booking From Website lilawalai.com";
$from = "\"$name\" <$email>";
$headers = "From: $from\nContent-type:text/html; charset=windows-874\n";
$msg = "Name: $name<br>E-mail: $email<br>Tel: $tel<br><br>
Check-In Date : $date_in <br>
Detail : <br>
-------------------------------------------------------------------------------------------------<br>
$detail<br>
-------------------------------------------------------------------------------------------------<br>
Total Nett Price : $sum <br>
-------------------------------------------------------------------------------------------------<br>
<br> Comment: <br> ";
//.nl2br($comment);
smtpmail($to, $subject, $msg, $headers);
//e-mail to customer
$subject ="Thank you for your booking Lilawalai Resort";
$msg2 = "
Dear $name,
Thank you for your booking Lilawalai Resort
Check-In Date : $date_in
Detail :
----------------------------------------------------------------------------------------------
$detail
----------------------------------------------------------------------------------------------
Total Nett Price : $sum
----------------------------------------------------------------------------------------------
Please kindly transfer money to our bank account as below details. We can accept payal at [email protected]
Krungsri Bank Office Seri Center
Account No. **********
Account Name Natthakran Mongkholsuvabundit.
Account Type saving
To guarantee your room please make your payment and fax pay-in slip to fax number 66.23 982855 or e-mail to [email protected] within 3 days from the date of booking.
Thank you for Booking at Lilawalai.
Natthakran Mongkholsuvabundit
Sales Manager
Tel. 02 398 3388\n";
$from = "From: $email\nReply-To: [email protected]\nReturn-Path: [email protected]";
smtpmail(strtolower($email) , $subject , $msg2 , $from);
echo redirect("pay.php");
exit;
}
?>
<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
<link rel="stylesheet" href="pattstyle.css" type="text/css">
<style type="text/css">
<!--
body {
background-image: url(images/bgg2.jpg);
}
-->
</style>
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<?include("head.php") ;?>
</td>
</tr>
<tr>
<td valign="top" background="images/tab.jpg">
<p> </p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="88%" valign="top"><br>
<img src="images/Reservation-Prices.gif">
<table width="100%" border="0" cellspacing="3" cellpadding="10" class="thai8">
<tr>
<td valign="top">
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="10" bgcolor="#FFFFFF">
<tr valign="top">
<td colspan="3">
<?include("room.php") ;?>
<div align="center"><br>
<br>
</div>
<table width="900" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="#FFCC33">
<tr>
<td width="100%" colspan="4" valign="top" bgcolor="#FFFFCC">
<p class="thai8 style26"><form method="post" action="<?= $PHP_SELF; ?>" name="cont_form">
<div align="center">
<table width="90%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4" class="thai8"><strong>Booking detail </strong></td>
</tr>
<tr>
<td colspan="4" class="thai8"><strong>Date In
<? $q1= "SELECT * FROM periodi$ann where idperiodi ='$s_date'";
$re1 = mysql_query($q1) or die(mysql_error());
$ro1= mysql_fetch_array($re1); echo"$ro1[datainizio] "?>
<input name="date_in" type="hidden" value="<?=$ro1[datainizio]?>" />
</strong></td>
</tr>
<tr>
<td width="48%" bgcolor="#99CC66" class="thai8">
<div align="left" class="style1"> Room Type
</div>
</td>
<td width="18%" bgcolor="#99CC66" class="thai8">
<div align="left" class="style1"> Cost</div>
</td>
<td width="18%" bgcolor="#99CC66" class="thai8">
<div align="left" class="style1"> Room</div>
</td>
<td width="16%" bgcolor="#99CC66" class="thai8">
<div align="left"><font color="#FFFFFF">Total
Price</font></div>
</td>
</tr>
<?
if(isset($_GET['nroom']) )
{
foreach ($_GET['nroom'] as $key => $value)
{
$ppid = explode(",",$key);
$type = $ppid[0];
$amount = $ppid[1];
$nightin = $ppid[2];
$num = $value;
if ($num !='0') { ?>
<tr bgcolor="#FFFFFF">
<td class="thai8" width="48%">
<?=$type?>
</td>
<td class="thai8" width="18%">
<? echo "$amount / $nightin Nights"; ?>
</td>
<td class="thai8" width="18%">
<?=$num?>
<div align="right"></div>
</td>
<? $total = $num *$amount;?>
<td class="thai8" width="16%">
<?=$total?>
<? $detail .= "
Room type: $type Cost: $amount / $nightin Nights | $num Rooms | Total :$total
";?>
<div align="left"></div>
</td>
</tr>
<? $sum +=$total; } }} ?>
<?=$sum32 = $sum; ?>
<tr>
<td colspan="3" bgcolor="#99CC66" class="thai8">
<div align="right"><font color="#FFFFFF"><strong>Total
Nett Price : </strong></font></div>
</td>
<td bgcolor="#99CC66" class="thai8" width="16%">
<div align="left"><font color="#FFFFFF">
<?=$sum?>
<input name="detail" type="hidden" value="<?=$detail?>" />
<input name="sum" type="hidden" value="<?=$sum?>" />
</font></div>
</td>
</tr>
</table>
</div>
<div align="center">
<p> </p>
<table width="90%" border="0" cellpadding="5" cellspacing="1" class="thai8">
<tr bgcolor="#99CC66">
<td colspan="2"><b><font color="#FFFFFF">Secure
Reservation Request Form</font></b></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="28%">Name</td>
<td width="72%">
<input name="name" type="text" class="infoBoxContent" size="35"onfocus="if (this.value=='your name'){this.value='';};return false;" onBlur="if (this.value==''){this.value='your name';return false;}">
<font color="#990000">*</font> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="28%">Email</td>
<td>
<input name="email" type="text" class="infoBoxContent" size="35" onFocus="if (this.value=='e-mail'){this.value='';};return false;" onBlur="if (this.value==''){this.value='e-mail';return false;}">
<font color="#990000">*</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="28%">Phone</td>
<td>
<input name="tel" type="text" class="infoBoxContent" size="35" onFocus="if (this.value=='phone'){this.value='';};return false;" onBlur="if (this.value==''){this.value='phone';return false;}">
<font color="#990000">*</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="28%">Detail</td>
<td>
<textarea name="comment" cols="33" class="infoBoxContent" onFocus="if (this.value=='comment'){this.value='';};return false;" onBlur="if (this.value==''){this.value='comment';return false;}"></textarea>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="28%"> </td>
<td valign="bottom">
<div align="left">
<input type="image" src="images/reset.jpg" onClick=" return form_reset(this.form);" name="image">
<input name="image" type="image" onClick='check_booking.php' src="images/submit.jpg" border="0">
</div>
</td>
</tr>
</table>
</div>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="thai8 style16"> </p>
<p class="thai8 style16"> </p>
</td>
</tr>
<tr>
<td background="images/tab.jpg">
<div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" colspan="3">
<?include("foot.php") ;?>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
Tag : PHP, MySQL, CakePHP
|
|
|
|
|
|
Date :
2013-06-13 16:18:59 |
By :
somjang |
View :
743 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บน host จริงต้องใช้ smtp ด้วยหรือเปล่าครับ
|
|
|
|
|
Date :
2013-06-13 16:25:10 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จากตัวอย่างมีการใช้ smtp จะต้องตรวจสอบ Username / Password ด้วยครับ
|
|
|
|
|
Date :
2013-06-13 17:07:09 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองแทรกนี้ไว้แถวๆบรรทัด 40 ดูครับ
Code (PHP)
ini_set("SMTP", "mail.lilawalai.com");
ini_set("smtp_port", "25");
|
|
|
|
|
Date :
2013-06-13 17:25:02 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|