我已经为我的网站设置了一个联系表单,但是我遇到了提交按钮的问题,一旦我点击它,我没有重定向到我的thank. youp,我已经尝试了很多东西来解决这个问题但是我有什么都没有运气。
它只是重定向到空白页面,您可以在此处测试提交表单http://www.sacredpurity.com/sacredpurity/contactform.php
以下是联系表格的代码
<i>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Sacred Puritys Online Store - Bringing you health and vitality</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/shop-homepage.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a href="http://www.sacredpurity.com/sacredpurity/index.html">Home</a>
</li>
<li>
<a href="http://www.sacredpurity.com/sacredpurity/about.html">About</a>
</li>
<li>
<a href="http://www.sacredpurity.com/sacredpurity/order.html">Order</a>
</li>
<li>
<a href="mailto:contact@sacredpurity.com">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<!-- Page Content --> <br><br><br><br>
<div class="container">
<div class="row">
<div class="col-md-3">
<img src="http://www.sacredpurity.com/sacredpurity/Images/spwebsitelogo.png">
<b><center><p class="lead">Our Products</p> </center></b>
<div class="list-group">
<a href="http://www.sacredpurity.com/sacredpurity/turpentine.html" class="list-group-item">Turpentine</a>
<a href="http://www.sacredpurity.com/sacredpurity/castoroil.html" class="list-group-item">Castor Oil</a>
<a href="http://www.sacredpurity.com/sacredpurity/activatedcharcoal.html" class="list-group-item">Activated Charcoal</a>
<a href="http://www.sacredpurity.com/sacredpurity/organiccoffee.html" class="list-group-item">Organic Coffee</a>
<a href="http://www.sacredpurity.com/sacredpurity/sugarcubes.html" class="list-group-item">Sugar Cubes</a>
<a href="http://www.sacredpurity.com/sacredpurity/enemakits.html" class="list-group-item">Enema Kits</a>
<a href="http://www.sacredpurity.com/sacredpurity/b12methylcobalamin.html" class="list-group-item">B12 Methylcobalamin</a>
<a href="http://www.sacredpurity.com/sacredpurity/niacin.html" class="list-group-item">Niacin (Vitamin B3)</a>
<a href="http://www.sacredpurity.com/sacredpurity/chromiumchelate.html" class="list-group-item">Chromium Chelate</a>
<br>
<br>
</div>
</div>
<?PHP
/*
Contact Form from HTML Form Guide
Contact Form from HTML Form Guide
This program is free software published under the
terms of the GNU Lesser General Public License.
See this page for more info:
http://www.html-form-guide.com/contact-form/php-contact-form-tutorial.html
*/
require_once("./include/fgcontactform.php");
require_once("./include/captcha-creator.php");
$formproc = new FGContactForm();
$captcha = new FGCaptchaCreator('scaptcha');
$formproc->EnableCaptcha($captcha);
//1. Add your email address here.
//You can add more than one receipients.
$formproc->AddRecipient('contact@sacredpurity.com'); //<<---Put your email address here
$formproc->SetFormRandomKey('n91LqHNvMrpoXte');
if(isset($_POST['submitted']))
{
if($formproc->ProcessForm())
{
$formproc->RedirectToURL("thank-you.php");
}
}
?>
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Contact us</title>
<link rel="STYLESHEET" type="text/css" href="contact.css" />
<script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
<script type='text/javascript' src='scripts/fg_captcha_validator.js'></script>
</head>
<body>
<font size="5">Contact Us</font> <br><br>
If you have a query please drop us a note using the form below.
<br><br>
The fastest way for us to respond is through our contact us form as we can respond throughout the day while we are busy packing orders for quick dispatch.
<br><br>
Please note that we are an online company that currently does not use any other forms of contact except via this contact form or email (contact@sacredpurity.com).
<br><br>
We will typically respond within hours of receiving your message.
<br><br>
<form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
<fieldset >
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text' class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
<div class='short_explanation'><font size="2"><b>* required fields</b></font></div>
<div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div>
<div class='container'>
<label for='name' >Your Full Name*: </label><br/>
<input type='text' name='name' id='name' value='<?php echo $formproc->SafeDisplay('name') ?>' maxlength="50" /><br/>
<span id='contactus_name_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='email' >Email Address*:</label><br/>
<input type='text' name='email' id='email' value='<?php echo $formproc->SafeDisplay('email') ?>' maxlength="50" /><br/>
<span id='contactus_email_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='message' >Message:</label><br/>
<span id='contactus_message_errorloc' class='error'></span>
<textarea rows="10" cols="50" name='message' id='message'><?php echo $formproc->SafeDisplay('message') ?></textarea>
</div>
<div class='container'>
<div><img alt='Captcha image' src='show-captcha.php?rand=1' id='scaptcha_img' /></div>
<label for='scaptcha' >Enter the code above here:</label>
<input type='text' name='scaptcha' id='scaptcha' maxlength="10" /><br/>
<span id='contactus_scaptcha_errorloc' class='error'></span>
<div class='short_explanation'>Can't read the image?
<a href='javascript: refresh_captcha_img();'>Click here to refresh</a>.</div>
</div>
<div class='container'>
<input type='submit' name='Submit' value='Submit' />
</div>
</fieldset>
</form>
<!-- client-side Form Validations:
Uses the excellent form validation script from JavaScript-coder.com-->
<script type='text/javascript'>
// <![CDATA[
var frmvalidator = new Validator("contactus");
frmvalidator.EnableOnPageErrorDisplay();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email address");
frmvalidator.addValidation("email","email","Please provide a valid email address");
frmvalidator.addValidation("message","maxlen=2048","The message is too long!(more than 2KB!)");
frmvalidator.addValidation("scaptcha","req","Please enter the code in the image above");
document.forms['contactus'].scaptcha.validator
= new FG_CaptchaValidator(document.forms['contactus'].scaptcha,
document.images['scaptcha_img']);
function SCaptcha_Validate()
{
return document.forms['contactus'].scaptcha.validator.validate();
}
frmvalidator.setAddnlValidationFunction("SCaptcha_Validate");
function refresh_captcha_img()
{
var img = document.images['scaptcha_img'];
img.src = img.src.substring(0,img.src.lastIndexOf("?")) + "?rand="+Math.random()*1000;
}
// ]]>
</script>
<!-- /.container -->
<center> <br>
<div class="container">
<hr>
<!-- Footer -->
<footer>
<div class="row">
<div class="col-lg-12">
<p> * This statement has not been evaluated by the Food and Drug Administration. This product is not intended to diagnose, treat, cure, or prevent any disease.
This dietary supplement is not a substitute for a licensed physician's medical advice. If any of its constituents, claims, or instructions herein conflict
with that of a treating licensed physician, defer to the opinion of the physician. This supplement and its supporting information is intended for people
in good health. It is the user's responsibility to know his or her medical history and ensure that supplements he or she takes do not create an adverse reaction.
<br><br>
Sacred Purity warrants that the products listed above and sold through our online system will be merchantable and free from material defects. Sacred Puritys makes
no other warranties, whether expressed or implied, including the implied warranty of fitness for a particular purpose. In the event that this product is found to
be defective, Sacred Puritys sole responsibility shall be to either refund the purchase price for the product or replace it with a product free of defects, at Sacred Puritys
option. Sacred Puritys shall not be responsible for any damage resulting from the improper use of this product. In addition, Sacred Puritys shall not be liable for
any special, indirect, consequential, exemplary or incidental damages, including, but not limited to, loss of profits or business opportunities.
<br><br>
Purchases of products/services from us are final and non-refundable. Cancellation or return of any individual component contained within a product package will require
the remaining items to be charged at full retail value. All associated shipment costs, including duties, customs and/or brokerage fees, are non-refundable and are the
responsibility of the customer. All products are non refundable.
<br><br>
Sacred Purity (hereinafter referred to as "we" and/or "us") operates FOB shipping point, freight prepaid. This means that the responsibility for the goods transfers
from us to buyer (hereinafter referred to as "you") the moment the package leaves our warehouse. Therefore we are NOT responsible for delays, losses, damages,
thefts, confiscations, additional postal fees in transit or at destination, taxes, etc. This list of events we are NOT responsible for is incomplete and may change
at any time. All claims about missing / damaged / delayed / confiscated / modified merchandise must be made directly with the shipping carrier, NOT us.
You should buy shipping insurance if you feel you need it, please contact us if you decide to insure your package. A processed order usually ships within two business
days unless noted, and we make a best effort to ship within one business day. For temporarily out of stock items or delayed shipments, you will be contacted by e-mail
or telephone. Our website does not display quantities available because the turnover is continuous. If an item is permanently unavailable or discontinued, the charge
will be voided or a complete refund will be made to your card. We will notify you if this occurs. Unless otherwise noted, all items ship directly from our shop base in
Thailand. Contact us via e-mail for alternative shipping method / carrier, special
orders or larger orders that you think warrant an insurance.
<br><br>
It is the sole responsibility of the client/buyer to ensure that the items ordered from our online store are permissible for mailing/receipt in the destination country.
We assume absolutely no responsibility for issues arising due to ordering prohibited/restricted items and any subsequent customs/legal issues in the destination or
transit countries. We are not responsible for any additional customs charges or fees once your package has left our facility. Customs charges and fees are the sole
responsibility of the purchaser. If you are unfamiliar with customs regulations, fees and charges, please speak to your local postal or customs office for more information.
If customs fees and charges are refused at the time of delivery, your order MAY be returned and you will not receive a refund for shipment costs. If a package is lost
in transit, confiscated by authorities, damaged, stolen, etc we are NOT responsible and the issue should be taken up with the local postal, custom, and law enforcement
authorities. Again, once a package is shipped we have no responsibility for it and we will offer no refund if something happens to it after shipping. If the package
is returned to us as undeliverable, please contact us to discuss what can be done to send it again.
<br><br>Copyright © Sacred Purity 2016</p> </center>
</div>
</div>
</footer>
</div>
<!-- /.container -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
此处还有一个页面,它意图重定向到称为thank-you.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Thank you!</title>
<link rel="STYLESHEET" type="text/css" href="contact.css">
</head>
<body>
<h2>Thanks for contacting us!</h2>
</body>
</html>
答案 0 :(得分:0)
假设您的RedirectToURL是一个接受参数作为URL的函数。尝试在您的函数中包含以下代码。如果在php结束标记之后没有发送标题,它将直接将标题设置为$ url,否则将使用javascript重定向。
function RedirectToURL($url)
{
if (!headers_sent())
{
header('Location: '.$url);
exit;
}
else
{
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
echo '</noscript>'; exit;
}
}