我有一个联系表格,当您单击“完成订单”时,它会检查某些字段是否为空。它应该刷新页面并显示错误消息。
但是我使用页面重命名(一些简单的方法来重命名页面并在同一个php页面上有多个页面)
所以我把联系表格放在 order.php?action=order
这是代码:
<?php
if(isset($_GET['action']) && $_GET['action'] != '') {
$action = $_GET['action'];
} else {
}
?>
<?php
if(isset($action)) {
if($action == 'order') {
?>
<div class="container">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform">
<fieldset>
<?php if(isset($hasError)) { //If errors are found ?>
<p class="alert-message error">Opps! Looks like you forgot to fill some specify field, please <b>go back</p> and fill the empty field.</p>
<?php } ?>
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
<div class="alert-message success">
<p style="color: white;" ><strong>Your Order has been Successfully Sent!</strong></p>
<p style="color: white;" >Thank you for submitting your order, <strong><?php echo $pname;?></strong>! Please check your Private Messages folder at <strong><?php echo $forum;?></strong>, as we will get back to you soon. You will redirect back to homepage in less than 5 seconds.<meta HTTP-EQUIV="REFRESH" content="5; url=http://justxp.plutohost.net/jonydesigns/index.php"></p>
</div>
<?php } ?>
<div class="formwarp">
<div class="tos1">
<input type="checkbox" id="new_info_yes" class="box1"> I agree to the <a href="#" style="color: #4fc5cf;" >Terms of Service</a>.
</div><br />
<div id="new_info_form">
<div class="clearfix">
<label for="subject">
<span class="coloring">Forums Name:</span>
</label>
<div class="input">
<select name="forumn" id="forumn" class="span6 required" role="select" aria-required="true">
<option value="slct">Please select a forum</option>
<option value="hackforums">Hackforums</option>
<option value="sythe">Sythe</option>
<option value="rune-server">Rune-Server</option>
</select>
</div>
<br />
<div id="slct" class="colors">You haven't selected any forum.</div>
<div id="hackforums" class="colors" style="display:none"> <span id="brdr">HackForums:</span> Discount Percent: <font color="green">10%</font> </div>
<div id="sythe" class="colors" style="display:none"> <span id="brdr">Sythe:</span> Discount Percent: <font color="green">15%</font> </div>
<div id="rune-server" class="colors" style="display:none"> <span id="brdr">Rune-Server:</span> Discount Percent: <font color="green">15%</font> </div>
<script type="text/javascript">
$(function() {
$('#forumn').change(function(){
$('.colors').hide();
$('#' + $(this).val()).show();
});
});
</script> </div>
<br />
<div class="clearfix">
<label for="name">
<span class="coloring">Forums Username:</span>
</label>
<div class="input">
<input type="text" name="forumuser" id="forumuser" value="" class="span6 required" role="input" aria-required="true" />
</div>
</div>
<div class="clearfix">
<label for="phone">
<span class="coloring">Personal Name:</span>
</label>
<div class="input">
<input type="text" name="pname" id="pname" value="" class="span6 required" role="input" aria-required="true" />
</div>
</div>
<div class="clearfix">
<label for="email">
<span class="coloring">Email Address:</span>
</label>
<div class="input">
<input type="text" name="email" id="email" value="" class="span6 required email" role="input" aria-required="true" />
</div>
</div>
<div class="clearfix">
<label for="email">
<span class="coloring">PayPal Email Address:</span>
</label>
<div class="input">
<input type="text" name="ppemail" id="ppemail" value="" class="span6 required email" role="input" aria-required="true" />
</div>
</div>
<div class="clearfix">
<label for="subject">
<span class="coloring">Product Type</span>
</label>
<div class="input">
<select name="product" id="product" class="span6 required" role="select" aria-required="true">
<option>Please select a product\project</option>
<option>PSD to HTML</option>
<option>Web Design</option>
<option>Thread Design</option>
<option>Logo Design</option>
<option>Banner Design</option>
<option>Thread design + Signature</option>
<option>Other (Please type in additional information field)</option>
</select>
</div>
</div><br />
<div style="margin-left: -13%;" id="line"></div><br />
<div class="clearfix">
<span class="coloring">Information</span>
<div class="input">
<textarea rows="8" name="message" id="message" class="span10 required" role="textbox" aria-required="true"></textarea>
</div>
</div>
<div class="clearfix">
<span class="coloring">View Information</span>
<div class="input">
<textarea rows="8" name="messageview" id="messageview" class="span10 required" role="textbox" aria-required="true"></textarea>
</div>
</div>
<div class="clearfix">
<label for="phone">
<span class="coloring">Additional Information:</span>
</label>
<div class="input">
<input type="text" name="additional" id="additional" value="Additional information regarding the product" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" class="span6 required" role="input" aria-required="true" />
</div>
</div>
<div class="clearfix">
<label for="phone">
<span class="coloring">PSD link:</span>
</label>
<div class="input">
<input type="text" name="psd" id="psd" value="PSD link here" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" class="span6 required" role="input" aria-required="true" />
</div>
</div>
<div class="clearfix">
<label for="phone">
<span class="coloring">Your Budget:</span>
</label>
<div class="input">
<input type="text" name="money" id="money" value="$0.00 Enter your budget" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" class="span6 required" role="input" aria-required="true" />
</div>
</div>
<div class="actionss">
<input type="submit" value="Complete Order" name="submit" id="submitButton" title="Click here to submit your message!" />
</div>
</fieldset>
</form>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('input#upload_yes').change(function(){
if($(this).is(':checked')) {
$("#upload_form").show();
} else {
$("#upload_form").hide();
}
});
$('input#new_info_yes').change(function(){
if($(this).is(':checked')) {
$("#new_info_form").slideDown(500);
} else {
$("#new_info_form").delay(300).slideUp(500);;
}
});
//Trigger the change event so the divs are initially shown or hidden.
$('input[type=checkbox]').trigger('change');
});
</script>
<?php
}
elseif($action == 'contact') {
?>
<!-- action=contact info here -->
<?php
}
}
?>
这将启动页面 ?action=order
<?php
if(isset($action)) {
if($action == 'order') {
?>
它显示表单并且一切正常。但是当您填写所有内容并单击完成订单时,它会重定向到 order.php 并且它不显示任何警报,如果订单已发送,它应该显示此警报:
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
<div class="alert-message success">
<p style="color: white;" ><strong>Your Order has been Successfully Sent!</strong></p>
<p style="color: white;" >Thank you for submitting your order, <strong><?php echo $pname;?></strong>! Please check your Private Messages folder at <strong><?php echo $forum;?></strong>, as we will get back to you soon. You will redirect back to homepage in less than 5 seconds.<meta HTTP-EQUIV="REFRESH" content="5; url=http://justxp.plutohost.net/jonydesigns/index.php"></p>
</div>
<?php } ?>
如果某些内容为空,则应显示此错误:
<?php if(isset($hasError)) { //If errors are found ?>
<p class="alert-message error">Opps! Looks like you forgot to fill some specify field, please <b>go back</p> and fill the empty field.</p>
<?php } ?>
但它根本不显示错误,它所做的只是将您重定向到 order.php 页面,但如果成功,它只会发送电子邮件但不会显示任何警报。
我该如何解决它或导致它发生的原因?
http://justxp.plutohost.net/jonydesigns/order.php?action=order
抱歉,代码很大,我只是不知道如何更清楚地问这个问题。