我购买了一个Dreamweaver模板,它带有一个Form页面。但是当我提交消息时,它会将我发送到另一个只有文本的页面。 所以我想改变它,所以它可以在提交按钮后显示一条消息。
这是插入HTML页面的联系表格:
<div class="col-sm-6 col-xs-12">
<div class="status alert alert-success contact-status"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php" role="form">
<div class="row">
<!-- Name Field Starts -->
<div class="col-md-6">
<div class="form-group">
<label for="name" class="sr-only">Nombre: </label>
<input type="text" class="form-control" name="name" id="name" required placeholder="NOMBRE">
</div>
</div>
<!-- Name Field Ends -->
<!-- Email Field Starts -->
<div class="col-md-6">
<div class="form-group">
<label for="email" class="sr-only">Correo Electrónico: </label>
<input type="text" class="form-control" name="email" id="email" required placeholder="EMAIL">
</div>
</div>
<!-- Email Field Ends -->
<!-- Phone No Field Starts -->
<div class="col-md-6">
<div class="form-group">
<label for="phoneno" class="sr-only">Teléfono: </label>
<input type="text" class="form-control" name="phoneno" id="phoneno" required placeholder="TELÉFONO (10 DÍGITOS)">
</div>
</div>
<!-- Phone No Field Ends -->
<!-- Message Field Starts -->
<div class="col-xs-12">
<div class="form-group">
<label for="message" class="sr-only">Mensaje: </label>
<textarea class="form-control" rows="8" name="message" id="message" required placeholder="MENSAJE"></textarea>
</div>
</div>
<!-- Message Field Ends -->
<div class="col-xs-12">
<input type="submit" class="btn btn-lg btn-block btn-secondary text-uppercase" value="Enviar Mensaje">
</div>
</div>
</form>
</div>
<!-- Contact Form Ends -->
这是sendemail.php
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Email sent!'
);
$name = @trim(stripslashes($_POST['name']));
$email = @trim(stripslashes($_POST['email']));
$phoneno = @trim(stripslashes($_POST['phoneno']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$email_from = $email;
$email_to = 'myemail@domain.com';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Phone NO: ' . $phoneno . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
?>
跳跃你可以帮助我