我需要帮助这个PHP代码...它没有重定向到指定的URL
<?php
if(isset($_POST['submit'])){
$to = "email@domain.com"; // this is your Email address
$firstName = $_POST['$inf_tTzSYWEgQfQ4dJf9'];
$lastName = $_POST['lastName'];
$phoneNumber = $_POST['phoneNumber'];
$company = $_POST['company'];
$addressLine1 = $_POST['addressLine1'];
$addressLine2 = $_POST['addressLine2'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$emailAddress = $_POST['emailAddress'];
$subject = "New Order - " . $firstName . " " . $lastName;
$body = "First Name: $firstName\n Last Name: $lastName\n Phone Number: $phoneNumber\n Company: $company\n Address Line 1: $addressLine1 \n Address Line 2: $addressLine2 \n City: $city\n State: $state\n Country: $country\n Email Address:$emailAddress";
header('Location: http://stackoverflow.com/');
}
?>
&#13;
这是HTML表单
<form method="post" name="orderForm" id="orderForm" action="ordersubmithandler.php">
<div id="header">
<div class="CUSTOM_HTML">
<div id="customHeader">
</div>
</div>
<div id="IMAGE">
<div id="companyLogoTopBanner">
<img src="orderpage_files/jp126-666e1bad-894a-41bd-9d30-be234e2bf638-v2.png">
</div>
</div>
</div>
<div id="content">
<input id="previewMode" name="previewMode" type="hidden" value="false">
<div id="ORDER_FORM_PRODUCT_LIST">
<table class="viewCart tabular grid">
<tbody>
<tr>
<th class="leftAlign">Products</th>
<th></th>
<th class="rightAlign priceCell">Price</th>
<th class="centerAlign qtyCell">Quantity</th>
<th class="rightAlign priceCell">Total</th>
</tr>
<tr>
<td colspan="2" class="productCell">
<h1>Lorem ip</h1>
<p class="productDescription">Lorem ipLorem ipLorem ipLorem ipLorem ipLorem ipLorem ipLorem ip</p>
<span class="subscriptionPlan">One Time Payment of $80.00</span>
</td>
<td class="rightAlign priceCell">
<span class="price">$80.00</span>
</td>
<td class="centerAlign qtyCell">1 </td>
<td class="rightAlign priceCell">$80.00</td>
</tr>
<tr class="subtotal">
<td class="leftAlign"><span class="totalPrice">Subtotal</span></td>
<td co="" colspan="2"></td>
<td class="qtyCell"></td>
<td class="rightAlign priceCell"><span class="priceBold">$80.00</span></td>
</tr>
</tbody>
</table>
</div>
<div id="CUSTOM_HTML">
<div id="productInformation">
<input name="" type="checkbox" checked="yes" value=""> <font color="black"><b> I understand and agree I will be charged one payment today of $80.00 as FULL payment for the product. </b></font><b> <br> <br>
</b></div>
</div>
<b>
<div id="UP_SELLS">
</div>
<div id="ORDER_FORM_BILLING_ENTRY">
<link href="./orderpage_files/anti_spam.jsp" rel="stylesheet" type="text/css">
<script type="text/javascript">(function() {
var styleArray = ["/css/anti_spam.jsp"];
if (window.Infusion) {
Infusion.stylesLoaded(styleArray);
} else if (window.InfusionStyles) {
window.InfusionStyles.concat(styleArray);
} else {
window.InfusionStyles = styleArray;
}
})();</script>
<div id="orderFormBillingEntry">
<table class="billingTable tabular grid">
<tbody>
<tr>
<th colspan="2" class="leftAlign">Billing Information</th>
</tr>
<tr>
<td class="rightAlignTop"><label class="checkoutLabel">* First Name</label></td>
<td>
<input class="regula-validation checkoutTop" data-constraints="@Required(label="First Name", groups=[customer])" id="firstName" name="firstName" size="10" type="text">
<input class="inf_a2f0ec38ba2014366540402764cde59e" id="inf_tTzSYWEgQfQ4dJf9" name="inf_tTzSYWEgQfQ4dJf9" type="text">
</td>
</tr>
<tr>
<td class="rightAlign"><label class="checkoutLabel">* Last Name</label></td>
<td><input class="regula-validation checkout" data-constraints="@Required(label="Last Name", groups=[customer])" id="lastName" name="lastName" size="12" type="text"></td>
</tr>
<tr>
<td class="rightAlign"><label class="checkoutLabel">Company Name</label></td>
<td><input class="checkout" id="company" name="company" size="25" type="text"></td>
</tr>
<tr>
<td class="rightAlign"><label class="checkoutLabel">* Address - Line 1</label></td>
<td><input class="regula-validation checkout" data-constraints="@Required(label="Address - Line 1", groups=[customer])" id="addressLine1" name="addressLine1" size="25" type="text"></td>
</tr>
<tr>
<td class="rightAlign"><label class="checkoutLabel">Address - Line 2</label></td>
<td><input class="checkout" id="addressLine2" name="addressLine2" size="25" type="text"></td>
</tr>
<tr>
<td class="rightAlign"><label class="checkoutLabel">* City</label></td>
<td><input class="regula-validation checkout" data-constraints="@Required(label="City", groups=[customer])" id="city" name="city" size="15" type="text"></td>
</tr>
<tr>
<td class="rightAlign"><label class="checkoutLabel"><div id="stateRequired">* State</div></label></td>
<td><select class="regula-validation checkout" data-constraints="@StateRequiredForSpecificCountries(countryFieldName="country", label="State", groups=[customer])" id="state" name="state" data-on="Component.Select"><option value="Lagos">Lagos</option></select></td>
</tr>
<tr>
<td class="rightAlign"><label class="checkoutLabel">* Country</label></td>
<td><select class="regula-validation checkout" data-constraints="@Required(label="Billing Country", groups=[customer])" id="country" name="country" data-on="Component.Select"><option value="Nigeria">Nigeria</option></select></td>
</tr>
<tr>
<td class="rightAlign">* Phone Number</td>
<td><input class="regula-validation checkout" data-constraints="@Required(label="Phone Number", groups=[customer])" id="phoneNumber" name="phoneNumber" size="25" type="text"></td>
</tr>
<tr>
<td class="rightAlign">* Email Address</td>
<td><input class="regula-validation checkoutBottom" data-constraints="@Required(label="Email Address", groups=[customer]) @Email(label="Email Address", groups=[customer])" id="emailAddress" name="emailAddress" size="15" type="text"></td>
</tr>
<tr>
<td> </td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">jQuery(document).ready(function() {
var $country = jQuery('#country');
if ($country.val() == 'United States' || $country.val() == 'Canada') {
jQuery('#stateRequired').html('* State');
}
if ($country.length > 0 && "SELECT" == $country.get(0).tagName) {
$country.change(function() {
if ($country.val() == 'United States' || $country.val() == 'Canada') {
jQuery('#stateRequired').html('* State');
} else {
jQuery('#stateRequired').html('State');
}
});
}
});
jQuery('#addressLine1, #city, #zipCode, #country, #state').change(function() {
Infusion.Ecomm.OrderForms.submitFormUponChangeOnBilling('orderForm', 'Profit-Academy-2015--Payment-Plan', 'RENDER_ORDER_FORM');
});</script>
</div>
<div id="ORDER_FORM_SHIPPING_ENTRY">
<div id="orderFormShippingEntry">
</div>
</div>
<div id="SHIPPING_OPTIONS">
<div id="shippingOptionsContainer">
</div>
</div>
<div id="PAYMENT_PLANS">
</div>
<div id="ORDER_FORM_SUMMARY">
<table class="orderSummary tabular grid">
<tbody>
<tr>
<th class="leftAlign">Summary Of What You Are Getting</th>
<th class="rightAlign"></th>
</tr>
<tr>
<td colspan="2">
<img src="bonus.png">
</td>
</tr>
<tr>
<th class="leftAlign">Order Summary</th>
<th class="rightAlign"></th>
</tr>
<tr>
<td class="listCell">Subtotal</td>
<td class="rightAlign">$80.00</td>
</tr>
<tr>
<td class="subtotal">Total Due</td>
<td class="rightAlign subtotal">$80.00</td>
</tr>
</tbody>
</table>
</div>
<div id="PAYMENT_SELECTION">
<table class="paymentMethodTable tabular grid">
<tbody>
<tr>
<td>
<button type="submit" style="align-content: center"><img src="bbbbbb.png" alt="a"></button>
</td>
</tr>
</tbody>
</table>
</div>
</b>
</div>
<b>
<br clear="all">
<div id="footer">
<div id="CUSTOM_HTML">
<div id="customFooter">
<!--<center><img src="./orderpage_files/payment-logos.jpg" alt="a"></center> --><br>
<center>
<font color="red">NOTICE: <i></i></font><i><font color="black"><b>Lorem ipsum, Please contact us at: <a href="mailto:mail@mail.com">mail@mail.com</a></b></font></i><b>
<br> <br>
<font color="black"><b>Copyright © . All rights reserved.<br></b></font>
<br>
<br>
<font color="black"><b> NEED HELP? Please contact us at: <a href="mailto:mail@mail.com">mail@mail.com</a> </b></font></b>
</center>
<b><font color="black"></font></b>
</div>
<b><font color="black"></font></b>
</div>
<b><font color="black"></font></b>
</div>
<b><font color="black"></font></b>
</b>
</form>
&#13;
我已尝试过多次编辑,但无法弄清楚代码有什么问题。
需要帮助...谢谢!
您的帮助真的非常值得赞赏:)
答案 0 :(得分:0)
它可能无法正常工作,因为您的按钮未被称为“提交”
<button type="submit" style="align-content: center">
尝试将name =“submit”放在那里..
另外,你总是可以在php代码中加入一些调试,所以它回应了它所做的检查值是你的想法..而且,你设置了一堆变量,什么也不做 - 没有你是指实际发送电子邮件?
答案 1 :(得分:0)
$_POST['$inf_tTzSYWEgQfQ4dJf9'];
的 $
不应该存在,因为它被视为另一个变量。
然后您的提交按钮未命名,这就是您的代码未在第一个条件语句中执行的原因。
您需要为其添加名称属性,如name="submit"
。