私はこのフォーラムで多くのことを試しましたが、リダイレクトを機能させることができません。私が書いた方法では、成功メッセージを含む新しいページが表示されますが、ユーザーはブラウザを介してバックアップするだけで、すべての情報が表示されたままになります。
成功メッセージのポップアップをクリアして表示するためのボックスが必要です。どうすればよいですか?
ありがとうございました、
これが私のphpです
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "lotusms@outlook.com";
$email_subject = "Your email subject line";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back with the browser back button and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['phone']) ||
!isset($_POST['email']) ||
!isset($_POST['service']) ||
!isset($_POST['bedrooms']) ||
!isset($_POST['bathrooms'])){
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$phone = $_POST['phone']; // required
$email_from = $_POST['email']; // required
$service = $_POST['service']; // required
$bedrooms = $_POST['bedrooms']; // not required
$bathrooms = $_POST['bathrooms']; // not required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The name you entered does not appear to be valid.<br />';
}
$string_exp = "/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/";
if(!preg_match($string_exp,$phone)) {
$error_message .= 'The number you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "The following quote has been requested. \n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Phone: ".clean_string($phone)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Service: ".clean_string($service)."\n";
$email_message .= "Bedrooms: ".clean_string($bedrooms)."\n";
$email_message .= "Bathrooms: ".clean_string($bathrooms)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
<?php
}
?>
これが私のフォームです
<form action="bin/quote.php" method="post" id="search" enctype="multipart/form-data" onSubmit="alert('Thank you!')"; >
<table summary="Search form" cellspacing="2" cellpadding="5">
<tr>
<th style="color:#c1c2c3; font-weight:bold">REQUEST A QUOTE</th>
</tr>
<tr>
<td colspan="5">Name: <input style="margin-left: 55px" type="text" class="text" name="name" /></td>
</tr>
<tr>
<td colspan="10">Phone:<input style="margin-left: 55px" type="text" class="text" name="phone" placeholder="XXX-XXX-XXXX" /></td>
</tr>
<tr>
<td colspan="5">Email:<input style="margin-left: 55px" type="text" class="text" name="email" /></td>
</tr>
<tr>
<th>Service Required:</th>
<td colspan="3">
<select name="service">
<option value="Residential Move">Residential Move*</option>
<option value="Commercial Move">Commercial Move*</option>
<option value="Storage Unit Loading">Storage Unit Loading</option>
<option value="Storage Unit Unloading">Storage Unit Unloading</option>
<option value="Furniture Consignment">Furniture Consignment</option>
<option value="Assembly/Removal">Assembly/Removal</option>
<option value="Landscaping">Landscaping</option>
<option value="Cleanout">Cleanout</option>
<option value="General Help">General Help</option>
</select>
</td>
</tr>
<tr>
<td style="color:#c1c2c3"><b>*If a move...</b></td>
</tr>
<tr>
<th>Bedrooms:</th>
<td>
<select name="bedrooms">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5+</option>
</select>
</td>
<th>Bathrooms:</th>
<td>
<select name="bathrooms">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5+</option>
</select>
</td>
</tr>
<tr>
<td><a onclick="document.getElementById('search').submit()"><button type="submit" value="SEND" class="more">Send</button></a></td>
</tr>
</table>
</form>
どんな助けでもありがたいです