我想創建一個非常基本的聯繫表單。我已經使用我所瞭解的語言知識編寫了HTML,Javascript和PHP,但它顯然不起作用。少了什麼東西?儘可能基本:jQuery聯繫表格
的HTML:
<form>
<fieldset>
<fieldset>
<input name="name" value="John Doe" size="30" /><br />
<input name="email" value="[email protected]" size="40" /><br />
</fieldset>
<fieldset>
<input type="text" name="subject" value="Subject" size="60" /><br />
<textarea name="message" rows="15" cols="100"></textarea><br /><br />
<input type="submit" value="Submit" />
<input type="button" value="Cancel" />
</fieldset>
</fieldset>
</form>
的JavaScript:
$('form').submit(function() {
$.ajax({
type: "POST",
url: "bin/process.php",
data: $(this).serialize(),
success: function() {
// Update page with success message
}
});
return false;
});
的PHP:
<?php
$recipient = "[email protected]"; //recipient
$Name = ($_POST['name']); //senders name
$email = ($_POST['email']); //senders e-mail adress
$mail_body = ($_POST['message']); //mail body
$subject = ($_POST['subject']); //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
mail($recipient, $subject, $mail_body, $header); //mail command :)
?>
什麼是不工作? – dockeryZ 2010-07-31 19:12:33
'.serialize()'是一種方法,而不是屬性。 – Harmen 2010-07-31 19:13:15
所以再次,究竟是什麼,它不工作 – dockeryZ 2010-07-31 19:15:55