我知道代码很长......但我希望我正在寻找的解决方案简单快捷。所以我有一个关于我的订单的会议。我有两种形式的回显,具体取决于该人是否已登录。首先,如果语句是用户是否已登录,它会执行所有这些操作(我知道代码并不完美,但它对我有用)。问题:下订单后如何将用户重定向到他们的帐户?我在 }else{... 不起作用之前尝试了 header 功能,直接将我带到了帐户页面。我在网上找不到代码,因为它们的表单都在 html 中,而不是在 php 中,所以标题不起作用。有什么建议???
<?php
$memberOrder = "";
$nonmemberOrder = "";
if(isset($_SESSION['id'])){
include_once "connect_to_mysql.php";
echo '<script type="text/javascript">
function validate_form ( ) {
var numbers = /^[0-9]+$/;
valid = true;
if ( document.memberOrder.memberNumber.value == "" ) {
alert ( "Membership number must be entered." );
valid = false;
}
if ( document.memberOrder.memberNumber.value.match(numbers)){
valid = true;
}else{
alert ( "You must only have numbers entered as Membership Number.");
valid = false;
}
if ( document.memberOrder.payment.value == "" ) {
alert ( "You must select a payment method." );
valid = false;
}
if ( document.memberOrder.orderLinks.value == "" ) {
alert ( "You must insert a link to your order." );
valid = false;
}
if ( document.memberOrder.size.value == "" ) {
alert ( "Size must not be blank." );
valid = false;
}
if ( document.memberOrder.cost.value == "" ) {
alert ( "Cost must not be blank." );
valid = false;
}
if ( document.memberOrder.cost.value.match(numbers)){
valid = true;
}else{
alert ( "You must only have numbers entered as your item cost.");
valid = false;
}
if (!document.memberOrder.checkbox.checked){
alert ( "You must agree to terms before placing your order.");
valid = false;
}
return valid;
}
</script>';
$memberNumber = preg_replace("[^0-9]", "", $_POST['memberNumber']);
$memberNumber = stripslashes($_POST['memberNumber']);
$size = preg_replace("[^a-zA-Z]", "", $_POST['size']);
$cost = preg_replace("[^0-9]", "", $_POST['cost']);
$cost = stripslashes($_POST['cost']);
$cost = strip_tags($cost);
$color = preg_replace("[^a-zA-Z]", "", $_POST['color']);
$color = stripslashes($_POST['color']);
$color = strip_tags($color);
$payment = $_POST['payment'];
$orderLinks = $_POST['orderLinks'];
$sql = mysql_query("INSERT INTO memberOrders (memberNumber, orderLinks, cost) VALUES
('$memberNumber', '$orderLinks', '$cost')") or die (mysql_error());
$memberOrder = '<form action="order.php" method="post" name="memberOrder" id="memberOrder" onsubmit="return validate_form ( );">
<table cellpadding="10" width="500px">
<tr>
<td><div align="left">Membership Number</div></td>
<td><input type="text" name="memberNumber" id="memberNumber" /></td>
</tr>
<tr>
<td><div align="left">Payment Type</div></td>
<td><input type="radio" name="payment" value="Bank Transfer" />Bank Transfer (recommended)<br/>
<input type="radio" name="payment" value="PayPal" />PayPal (additional 3% commission)<br/>
<input type="radio" name="payment" value="Western Union" />Western Union<br/>
<input type="radio" name="payment" value="MoneyGram" />MoneyGram<br/>
</td>
</tr>
<tr>
<td><div align="left">Link To Your Order</div></td>
<td><textarea rows="5" cols="20" name="orderLinks" ></textarea></td>
</tr>
<tr>
<td><div align="left">Size</div></td>
<td><input style="width:50px" type="text" size="25px" name="size" /></td>
</tr>
<tr>
<td><div align="left">Color</div></td>
<td><input type="text" size="25px" name="color" /></td>
</tr>
<tr>
<td><div align="left">Cost of Your Item</div></td>
<td><input style="width:50px" type="text" name="cost" /></td>
</tr>
<tr>
<td><div align="left">Order Agreement</div></td>
<td><input type="checkbox" name="checkbox" checked="checked" value="check" /><a href="#" id="agreement">View Order Agreement</a></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Place Order!" /></td>
</tr>
</table>
</form>';
echo $memberOrder;
// Start assembly of Email Member the activation link
$to = "yankeesmarket@gmail.com";
// Change this to your site admin email
$from = "$memberNumber";
$subject = "Member Order Placed";
//Begin HTML Email Message where you need to change the activation URL inside
$message = '<html>
<body bgcolor="#FFFFFF">
Member Number: '.$memberNumber.' <br/><br/>
Payment Type: '.$payment.' <br/><br/>
Order Links: '.$orderLinks.' <br/><br/>
Size: '.$size.' <br/><br/>
Color: '.$color.' <br/><br/>
Order Cost: '.$cost.' <br/><br/>
</body>
</html>';
// end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to";
// Finally send the activation email to the member
mail($to, $subject, $message, $headers);
}else{