我得到我的腳與形式處理溼,所以忍受着我。我有一個基本的HTML表單和一個發送郵件的腳本。目前它發送並刷新以提供反饋。我想要的是如果反饋可以在不刷新頁面的情況下給出。沒有頁面刷新的形式反饋
HTML
<html>
<head>
<title>E-Mail Form</title>
</head>
<body>
<form action="beta_sendmail.php" method="POST">
<p><strong>Name: </strong><br/>
<input type="text" size="25" name="name" /></p>
<p><strong>E-Mail Address: </strong><br />
<input type="text" size="25" name="email" /></p>
<p><strong>Message: </strong><br />
<textarea name="message" cols="30" rows="5"></textarea></p>
<p><input type="submit" value="send" /></p>
</form>
</body>
</html>
和PHP
<html>
<head>
<title>Mail Sending Script</title>
</head>
<body>
<?php
echo "<p>Thank you, <b>".$_POST["name"]."</b>, for your message!</p>";
echo "<p>Your email address is: <b>".$_POST["email"]."</b>.</p>";
echo "<p>Your message was: <br/>";
echo $_POST["message"]."</p>";
//start building the mail string
$msg = "Name: ".$_POST["name"]."\n";
$msg .= "E-Mail: ".$_POST["email"]."\n";
$msg .= "Message: ".$_POST["message"]."\n";
//set up the mail
$recipient = "[email protected]";
$subject = "Form Submission Results";
$mailheaders = "From: My Web Site <[email protected]> \n";
$mailheaders = "Reply-To: ".$_POST["email"];
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>
</body>
</html>
爲此,你需要AJAX。開始在這裏尋找並獲得基本的AJAX教程。 JavaScript庫(特別是jQuery)使得開始非常容易... – 2012-02-16 15:27:14
您的問題得到了解答嗎?如果不是,我們需要反饋。 – James 2012-02-16 16:54:34
到目前爲止,我只能標記出那些有用的答案。一旦我已經通過答案和建議,我會讓你知道;) – Andy 2012-02-16 17:34:10