表单操作是“”,因为它都使用相同的页面。无论如何表单可以在同一页面上提交而不刷新?
PHP:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$to="josue.espinosa@mtchs.org";
$subject="Tech Muffins Contact";
$message="Name: ".$_REQUEST['name']."\n\nEmail: ".$_REQUEST['email']."\n\nMessage: ".$_REQUEST['message'];
$from = "donotreply@techmuffins.com";
$headers = "From:" . $from;
mail($to, $subject, $message, $headers );
}
?>
HTML:
<form id="contactform" action="" method="post" autocomplete="off">
<input type="text" name="name" placeholder="name" autofocus required>
<input type="email" id="email" name="email" placeholder="email" required>
<textarea name="message" placeholder="message" required></textarea>
<input type="submit" value="submit">
</form>