|
|
|
send mail...พอดีสร้างฟอร์มสำหรับ add ดาต้าลงฐานข้อมูลได้แล้ว แต่ว่าตอนคลิก submit อยากให้มีการส่งข้อความแจ้งเมล์ |
|
|
|
|
|
|
|
ตัวหากินของผมน่ะเนี้ย ขอเเบ่งปัน ติดตรงไหนก็บอก ได้ครับ หรือ ใครอยากปรับเปลี่ยนตรงไหนก็ยิ่งดี
หน้า contact.html
Code (PHP)
<table border="0" cellpadding="0" cellspacing="1">
<form action="contactus.php" method="post" name="contact" id="contact" onSubmit="return checkform()">
<tr>
<td width="150" valign="middle" class="text">Your Name: </td>
<td width="250" valign="middle" ><input name="name" type="text" class="contact" id="name" maxlength="20"/></td>
</tr>
<tr>
<td valign="middle" class="text">E-mail: </td>
<td valign="middle"><input name="email" type="text" class="contact" id="email" maxlength="50"/></td>
</tr>
<tr>
<td valign="middle" class="text">Telephone: </td>
<td valign="middle" ><input name="telephone" type="text" class="contact" id="telephone" maxlength="20"/></td>
</tr>
<tr>
<td valign="middle" class="text">Enquiry</td>
<td valign="top"><textarea name="enquiry" rows="3" id="enquiry" class="contact"></textarea></td>
</tr>
<tr>
<td height="35"align="right" valign="top" class="text"> </td>
<td valign="middle"><label>
<input name="Submit" type="submit" class="submit" value="Submit" />
<input name="Reset" type="reset" class="submit" value="Reset" />
</label></td>
</tr>
</form>
</table>
หน้า contactus.php
Code (PHP)
<?php
//$con = mysql_connect("host","user","password");
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$datetime=date("Y-m-d H:i:s");
$ipaddress = $_SERVER['REMOTE_ADDR']; //Get user IP
$browser = $_SERVER['HTTP_USER_AGENT']; //Get user browser
echo $ipaddress;
echo $browser;
mysql_select_db("dbname", $con);
$sql="INSERT INTO tblcontact (name,email,telephone,enquiry,datetime,ipaddress,browser)
VALUES
('$_POST[name]','$_POST[email]','$_POST[telephone]','$_POST[enquiry]','$datetime','$ipaddress','$browser')";
mysql_query($sql);
$id = mysql_insert_id();
echo $id;
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Thank you for your submit";
mysql_close($con)
?>
<style type="text/css">
<!--
body {
margin: 0px;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
}
-->
</style>
<?
$to = "[email protected]";
$subject = "Enquiry ID:".$id." to mydomain.com";
$msg ="
<html>
<body>
<hr size='1'>
Enquiry ID:".$id."<br>
Name:".$_POST[name]."<br>
Email: ".$_POST[email]."<br>
Telephone: ".$_POST[telephone]."<br>
Enquiry: ".$_POST[enquiry]."<br><br>
IP Address: ".$ipaddress."<br>
Browser Info: ".$browser."
<hr size='1'>
</body>
</html>
";
//echo $msg;
//echo " hello ";
if(ereg(",",$_POST[email])|| ereg(";",$_POST[email])){
?>
<?
}
else{
$headers = "From: $_POST[email]\n";
//$headers .= "bcc: [email protected]\n";
$headers.= "Content-Type: text/html; charset=tis-620";
#mail("$to","$subject", "$msg", "$headers");
mail("$to","$subject", "$msg", "$headers");
echo '<meta http-equiv="refresh" content="0;URL=thank-you.html">';
}
// Auto Reply respond
$receiver ="[email protected]";
$email = $_POST['email'];
$subject = 'Thank you for your Enquiry ID:'.$id.'' ; // change subject
$message = 'Dear '.$_POST[name].'
Thank you for your email enquiry to mydomain.com
We will reply shortly to your enquiry.
If you have any questions or comments, feel free to contact us.
Best Regards,
mydomain.com
==========================================
website http://www.mydomain.com
email: mydomain.com
==========================================
'; // change text
mail($email, $subject, $message, 'From:'.$receiver.''); // send another one out
?>
<title>Enquiry to mydomain.com</title>
|
|
|
|
|
Date :
2010-05-14 08:36:49 |
By :
rod |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณนะครับขอเอาไปทดลองก่อนครับ
บอร์ดแห่งนี้ที่ไม่เคยแล้งน้ำใจกันเลย มีทางออกให้กันเสมอ
|
|
|
|
|
Date :
2010-05-14 12:41:55 |
By :
php Beginner |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|