我有一个带有 php 表单提交的 html 页面,它非常基本.. 我现在要做的是提交,然后转到一个空白页面,上面写着“谢谢”等,但我在看什么要做的是当用户提交表单时,它会弹出一个窗口或灯箱,上面写着“谢谢提交”。我怎样才能做到这一点?这是表单的 html 代码,以及提交的实际 php 代码。
html代码:
<form method="post" action="includes/buy.php">
<h2> Sizes: </h2><select name="sizes"><option value="1">1</option></select>
<h2> Email: </h2><input type="text" name="email" />
<input type="hidden" value="black" name="color" />
<input type="image" value="submit" src="images/buynow.jpg" />
</form>
php表单提交代码:
<?php
if(isset($_POST['email'])) {
$email_to = " ";
$email_subject = "subject line here";
function died($error) {
echo "We're sorry, but there's errors found with the form you submitted.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
if(!isset($_POST['email'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$email_from = $_POST['email'];
$color = $_POST['color'];
$sizes = $_POST['sizes'];
$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 />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details:\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Size: ".clean_string($sizes)."\n";
$email_message .= "Color: ".clean_string($color)."\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);
?>
<?php
}
die();
?>