0

我已经搜索和搜索,无法找到解决此问题的方法。我需要将此表格添加到 wordpress 作为外卖店的在线订单表格 - 但我根本无法发送表格(电子邮件)!它不断重定向到管道搜索 - 找不到页面。请帮忙。我是一名平面设计师,而不是真正的编码员。这是代码:

<form name="onlineOrder" method="post" action="take-away-menu"><br>


<div id="costEntry">
  <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Take Away Menu</h1>
  <ul>
<li><input name="menuItem[]" type="checkbox" value="35">Fish & chips R35<br></li>
<li><input name="menuItem[]" type="checkbox" value="38">Russian & chips R38</li>
<li><input name="menuItem[]" type="checkbox" value="45">Full Chicken R45<br></li>
<li><input name="menuItem[]" type="checkbox" value="30">Half Chicken R30<br></li>
<li><input name="menuItem[]" type="checkbox" value="22">Quarter Chicken R22<br></li>
<li><input name="menuItem[]" type="checkbox" value="10">One chicken piece R10</li>
</ul>
<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Toasted Sandwiches</h1>
<ul>
<li><input name="menuItem[]" type="checkbox" value="35">Bacon Cheese & Egg R26<br>   
</li>
<li><input name="menuItem[]" type="checkbox" value="25">Bacon Cheese & Tomato   
R25<br></li>
<li><input name="menuItem[]" type="checkbox" value="21">Ham Cheese & Tomato R21<br>    
</li>
<li><input name="menuItem[]" type="checkbox" value="19">Cheese & Tomato R19<br></li>
<li><input name="menuItem[]" type="checkbox" value="15">Cheese R15<br></li>
<li><input name="menuItem[]" type="checkbox" value="25">Chicken & Mayo R25</li>
</ul>   
<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Lunch Baskets</h1>
<ul>
<li><input name="menuItem[]" type="checkbox" value="39">&nbsp;&nbsp;&nbsp;Rib    
Fingers,<br>
Chicken Strips<br>
Chicken wings<br>
All with chips R39</li>
</ul>
<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Chips</h1>
<ul>
<li><input name="menuItem[]" type="checkbox" value="13" >Regular R13<br></li>
<li><input name="menuItem[]" type="checkbox" value="25">Medium R25<br></li>
<li><input name="menuItem[]" type="checkbox" value="30">Large R30<br></li>
</ul>  
<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Home made Pies</h1>
<ul>
<li><input name="menuItem[]" type="checkbox" value="15" >Assorted R15</li>
</ul>
<label><strong>Total R</strong></label>
<input type="text" id="totalcost" width="100px" align="left" value="">
</div><br>
   <br>
<label>Name:</label><br>
<input name="name" placeholder="Your name" width="200px" padding="10px" border="1px   
 solid #dedede" color="3a3a3a" height="12px" margin-top="3px"><br>
<br>

<label>Contact Number:</label><br>
<input name="contact number" placeholder="Your contact number" width="200px" padding="10px" border="1px solid #dedede" color="3a3a3a" height="12px" margin-top="3px"><br>
<br>

<label>Email</label><br>
<input name="email" type="email" placeholder="Your email address" width="200px"   
 padding="10px" border="1px solid #dedede" color="3a3a3a" height="12px" margin-    
 top="3px"><br>
<br>

<label>Address</label><br>
<textarea name="address" placeholder="Your physical address" width="439px"   
padding="10px" border="1px solid #dedede" color="3a3a3a" height="12px" margin-
top="3px"></textarea><br>

<label>Message</label><br>
<textarea name="message" placeholder="Type Here" width="439px" padding="10px" border="1px solid #dedede" color="3a3a3a" height="27px" margin-top="3px"></textarea><br>

<label>* 2+2= ? (Anti-spam)</label><br>
<input name="human" placeholder="answer"><br>

<input id="submit" name="submit" type="submit" value="Submit">

</form>

<script type="text/javascript">

function UpdateCost() {
  var sum = 0;
    var sel = document.getElementById('costEntry').getElementsByTagName('input');
  for (i=0; i<sel.length; i++) {
    if (sel[i].checked == true) { sum += Number(sel[i].value); }
  } document.getElementById('totalcost').value = sum.toFixed(2);
} 

window.onload = function() {
  var sel = document.getElementById('costEntry').getElementsByTagName('input');
  for (var i=0; i<sel.length; i++) {
    sel[i].onclick = function () { UpdateCost(); }
  }
}
</script>

<?php

// insure form variables exist
$name           = isset($_POST['name'])             ? $_POST['name']               
: '';
$contactnumber  = isset($_POST['contactnumber'])    ? $_POST['contactnumber']    
: '';
$email          = isset($_POST['email'])            ? $_POST['email']           
: '';
$address        = isset($_POST['address'])          ? $_POST['address']           
: '';
$message        = isset($_POST['message'])          ? $_POST['message']         
: '';
$menuItem       = isset($_POST['menuItem'])         ? $_POST['menuItem']        
: '';
$human          = isset($_POST['human'])            ? $_POST['human']           
: '';
 $submit        = isset($_POST['submit'])           ? true                         
: false;

$project = isset($_POST['menuItem'])
     ? implode(', ', $_POST['menuItem'])     // gather selected checkboxes
     : 'No menu item selected';             // (Unsure of translation)


$from = 'From: www.mydomaon.co.za'; 
$to = 'me@mydomain.co.za'; 
$subject = 'online order';

$body = 
"From: $name\n 
Contact: $contact number\n 
E-Mail: $email\n 
Physical Address: $physical address\n 
Message: $Message\n 
Menu Item: $Menu Item\n";
if ($_POST['submit'] && $human == '4') {                 
if (mail ($to, $subject, $body, $from)) { 
print ("Thank You");
/*echo '<p>Your order was sent!</p>';*/
} else { 
echo '<p>Oops, something went wrong. Please try again.</p>'; 
} 
} else if ($_POST['submit'] && $human != '4') {
/*echo '<p>The anti-spam answer is incorrect.</p>';*/
}
?>
<?php get_footer(); ?>'
4

1 回答 1

0

Replace this line

<form name "onlineOrder" method="post" action="take-away-menu">

with this line

<form name="onlineOrder" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">

I will work.

于 2013-09-06T05:29:07.203 回答