我正在寻找一种通过电子邮件发送具有相同HTML结果的产品确认页(带有可用输入)的解决方案。我对从mail.php的确认页面获取输入不感到困惑。请在下面找到代码。谢谢
stockdetailform.php
<html>
<head>
<title>Stockr Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Stock Form</h1>
<form action="confirmation.php" method="post">
<p> Enter Total No. of iPad Air2:
<input type="text" name="ipadair2" size="30">
</p>
<p> Enter Total No. of iPhone6:
<input type="text" name="iphone6" size="30">
</p>
<p> Enter Total No. of iMac:
<input type="text" name="imac" size="30">
</p>
<p>
<button type="submit">Generate Report</button>
</p>
</form>
</body>
</html>
Confirmation.php
<html>
<title>Confirm Order</title>
<head>
</head>
<body>
<div style="width:850px; margin-left:auto; margin-right:auto; margin-top:150px;">
<h2>Confirm Order</h2>
<?php
//Get the input.
$ipadair2 = $_POST['ipadair2'];
$iphone6 = $_POST['iphone6'];
$imac = $_POST['imac'];
//Compute totals.
$stock_total = $ipadair2 + $iphone6 + $imac ;
//Output totals.
if(isset($_POST['ipadair2']) && is_numeric($_POST['ipadair2'])){
$ipadair2 = $_POST['ipadair2'];
} else {
$ipadair2 = 0;
}
if(isset($_POST['iphone6']) && is_numeric($_POST['iphone6'])){
$iphone6 = $_POST['iphone6'];
} else {
$iphone6 = 0;
}
if(isset($_POST['imac']) && is_numeric($_POST['imac'])){
$imac= $_POST['imac'];
} else {
$imac= 0;
}
?>
<table width="850" border="0" cellpadding="5" cellspacing="0" style="border:1px solid #ccc;">
<tr bgcolor="#f7f7f7" >
<th width="696" height="37" align="left" style="border-bottom:1px solid #ccc;">Product</th>
<th width="128" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;">Quantity</th>
</tr>
<?php
if($ipadair2 > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">ipadair2</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $ipadair2; ?></td>
</tr>
<?php
}
?>
<?php
if($iphone60 > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">iphone6</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $iphone6; ?></td>
</tr>
<?php
}
?>
<?php
if($imac > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">imac</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $imac; ?></td>
</tr>
<?php
}
?>
<tr>
<td height="55" ><strong>Total Items</strong></td>
<td align="center" width="128"><?php print $quote_total; ?></td>
</tr>
<tr>
<td colspan="2"><form method="post" action="mail.php">
<input type='hidden' name='ipadair2' value='<?php if(isset($ipadair2) && $ipadair2 >0){echo $ipadair2;}else{echo "0";} ?>'>
<input type='hidden' name='iphone6' value='<?php if(isset($iphone6) && $iphone6 >0){echo $iphone6;}else{echo "0";} ?>'>
0){echo $ imac;} else {echo“ 0”;}?>'>
/ td>
mail.php
<?php
/* Subject and email variables */
$emailsSubject = 'STOCK STATUS';
$webMaster = '[email protected]';
//Get the input.
$ipadair2 = $_POST['ipadair2'];
$iphone6 = $_POST['iphone6'];
$imac = $_POST['imac'];
//Compute totals.
$stock_total = $ipadair2 + $iphone6 + $imac ;
//Output totals.
if(isset($_POST['ipadair2']) && is_numeric($_POST['ipadair2'])){
$ipadair2 = $_POST['ipadair2'];
} else {
$ipadair2 = 0;
}
if(isset($_POST['iphone6']) && is_numeric($_POST['iphone6'])){
$iphone6 = $_POST['iphone6'];
} else {
$iphone6 = 0;
}
if(isset($_POST['imac']) && is_numeric($_POST['imac'])){
$imac= $_POST['imac'];
} else {
$imac= 0;
}
?>
$body = <<<EOD
<table width="850" border="0" cellpadding="5" cellspacing="0" style="border:1px solid #ccc;">
<tr bgcolor="#f7f7f7" >
<th width="696" height="37" align="left" style="border-bottom:1px solid #ccc;">Product</th>
<th width="128" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;">Quantity</th>
</tr>
<?php
if($ipadair2 > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">ipadair2</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $ipadair2; ?></td>
</tr>
<?php
}
?>
<?php
if($iphone60 > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">iphone6</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $iphone6; ?></td>
</tr>
<?php
}
?>
<?php
if($imac > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">imac</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $imac; ?></td>
</tr>
<?php
}
?>
<tr>
<td height="55" ><strong>Total Items</strong></td>
<td align="center" width="128"><?php print $quote_total; ?></td>
</tr>
<tr>
<td colspan="2"><form method="post" action="mail.php">
<input type='hidden' name='ipadair2' value='<?php if(isset($ipadair2) && $ipadair2 >0){echo $ipadair2;}else{echo "0";} ?>'>
<input type='hidden' name='iphone6' value='<?php if(isset($iphone6) && $iphone6 >0){echo $iphone6;}else{echo "0";} ?>'>
<input type='hidden' name='imac' value='<?php if(isset($imac) && $imac >0){echo $imac;}else{echo "0";} ?>'>
<input type="submit" value="SEND MAIL" name='submit' >/td>
</tr>
</table>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
/* This is what sends the email */
$success = mail($webMaster, $emailsSubject, $body, $headers);
/* Results Rendered as Html */
echo file_get_contents("http://yourdomain.com/after-message-sent/");
?>
正在跟踪结果(电子邮件)
mail.php,无需任何计算
<?php
//Get the input.
$ipadair2 = $_POST['ipadair2'];
$iphone6 = $_POST['iphone6'];
$imac = $_POST['imac'];
/* Subject and email variables */
$emailsSubject = 'STOCK STATUS';
$webMaster = '[email protected]';
/* What You Want To See In The Email Place Inbetween $body = <<<EOD and EOD; */
$body = <<<EOD
<table width="850" border="0" cellpadding="5" cellspacing="0" style="border:1px solid #ccc;">
<tr bgcolor="#CCCCCC" >
<th width="696" height="37" align="left" style="border-bottom:1px solid #ccc; font-size:18px;">Product</th>
<th width="128" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc; font-size:18px;">Quantity</th>
</tr>
<tr bgcolor="#F9F9F9" >
<td height="32" style="border-bottom:1px solid #ccc;"><strong>iPadair2</strong></td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc; color:#15c; font-weight:bold;">$ipadair2</td>
</tr>
<tr >
<td height="32" style="border-bottom:1px solid #ccc;"><strong>iPhone6</strong></td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc; color:#15c;font-weight:bold;">$iphone6</td>
</tr>
<tr bgcolor="#F9F9F9">
<td height="32" style="border-bottom:1px solid #ccc;"><strong>iMac</strong></td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc; color:#15c;font-weight:bold;">$imac</td>
</tr>
</table>
<br />
<br />
EOD;
/* Headers is a tag containing the users email and how you want it to display in your email */
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
/* This is what sends the email */
$success = mail($webMaster, $emailsSubject, $body, $headers);
/* Results Rendered as Html */
echo file_get_contents("http://yourdomain.com/after-message-sent/");
?>
参考方案
更正了一些错误,即未设置stock_total等,应立即运行
Stackdetail.php
<html>
<head>
<title>Stockr Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Stock Form</h1>
<form action="confirmation.php" method="post">
<label for ="email">Enter your Email
<input type="email" name="email" />
</label>
<p> Enter Total No. of iPad Air2:
<input type="text" name="ipadair2" size="30">
</p>
<p> Enter Total No. of iPhone6:
<input type="text" name="iphone6" size="30">
</p>
<p> Enter Total No. of iMac:
<input type="text" name="imac" size="30">
</p>
<p>
<button type="submit">Generate Report</button>
</p>
</form>
</body>
</html>
Confirmation
<html>
<title>Confirm Order</title>
<head>
</head>
<body>
<div style="width:850px; margin-left:auto; margin-right:auto; margin-top:150px;">
<h2>Confirm Order</h2>
<?php
//Get the input.
$ipadair2 = $_POST['ipadair2'];
$iphone6 = $_POST['iphone6'];
$imac = $_POST['imac'];
$email= $_POST['email'];
//Compute totals.
$stock_total = $ipadair2 + $iphone6 + $imac ;
//Output totals.
if(isset($_POST['ipadair2']) && is_numeric($_POST['ipadair2'])){
$ipadair2 = $_POST['ipadair2'];
} else {
$ipadair2 = 0;
}
if(isset($_POST['iphone6']) && is_numeric($_POST['iphone6'])){
$iphone6 = $_POST['iphone6'];
} else {
$iphone6 = 0;
}
if(isset($_POST['imac']) && is_numeric($_POST['imac'])){
$imac= $_POST['imac'];
} else {
$imac= 0;
}
?>
<table width="850" border="0" cellpadding="5" cellspacing="0" style="border:1px solid #ccc;">
<tr bgcolor="#f7f7f7" >
<th width="696" height="37" align="left" style="border-bottom:1px solid #ccc;">Product</th>
<th width="128" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;">Quantity</th>
</tr>
<?php
if($ipadair2 > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">ipadair2</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $ipadair2; ?></td>
</tr>
<?php
}
?>
<?php
if($iphone6 > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">iphone6</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $iphone6; ?></td>
</tr>
<?php
}
?>
<?php
if($imac > 0){
?>
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">imac</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;"><?php print $imac; ?></td>
</tr>
<?php
}
?>
<tr>
<td height="55" ><strong>Total Items</strong></td>
<td align="center" width="128"><?php print $stock_total; ?></td>
</tr>
<tr>
<td colspan="2"><form method="post" action="mail.php">
Your Confirmation email will be sent to : <?php echo " $email "; ?>
<input type='hidden' name="email" value='<?php if(isset($email)){echo $email;}?>'>
<input type='hidden' name='imac' value='<?php if(isset($imac) && $imac >0){echo $imac;}else{echo "0";} ?>'>
<input type='hidden' name='ipadair2' value='<?php if(isset($ipadair2) && $ipadair2 >0){echo $ipadair2;}else{echo "0";} ?>'>
<input type='hidden' name='iphone6' value='<?php if(isset($iphone6) && $iphone6 >0){echo $iphone6;}else{echo "0";} ?>'>
<input type="submit" value="Confirm Order" />
mail.php
<?php
/* Subject and email variables */
$emailsSubject = 'STOCK STATUS';
$webMaster = '[email protected]';
$email= $_POST['email']; //Get the input.
$ipadair2 = $_POST['ipadair2'];
$iphone6 = $_POST['iphone6'];
$imac = $_POST['imac'];
//Compute totals.
$stock_total = $ipadair2 + $iphone6 + $imac ;
//Output totals.
if(isset($_POST['ipadair2']) && is_numeric($_POST['ipadair2'])){
$ipadair2 = $_POST['ipadair2'];
} else {
$ipadair2 = 0;
}
if(isset($_POST['iphone6']) && is_numeric($_POST['iphone6'])){
$iphone6 = $_POST['iphone6'];
} else {
$iphone6 = 0;
}
if(isset($_POST['imac']) && is_numeric($_POST['imac'])){
$imac= $_POST['imac'];
} else {
$imac= 0;
}
$body = '
<table width="850" border="0" cellpadding="5" cellspacing="0" style="border:1px solid #ccc;">
<tr bgcolor="#f7f7f7" >
<th width="696" height="37" align="left" style="border-bottom:1px solid #ccc;">Product</th>
<th width="128" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;">Quantity</th>
</tr>';
if($ipadair2 > 0){
$body.='
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">ipadair2</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;">'.$ipadair2.'</td>
</tr>';
}
if($iphone6 > 0){
$body.=
'<tr>
<td height="32" style="border-bottom:1px solid #ccc;">iphone6</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;">'. $iphone6.'</td>
</tr>';
}
if($imac > 0){
$body.='
<tr>
<td height="32" style="border-bottom:1px solid #ccc;">imac</td>
<td align="center" style="border-bottom:1px solid #ccc; border-left:1px solid #ccc;">'. $imac.'</td>
</tr>';
}
$body .='
<tr>
<td height="55" ><strong>Total Items</strong></td>
<td align="center" width="128">'.$stock_total.'</td>
</tr>
<tr>
<td colspan="2"><form method="post" action="mail.php">';
$body .=" <input type='hidden' name='email' value='$email'>
<input type='hidden' name='ipadair2' value='$ipadair2'>
<input type='hidden' name='iphone6' value='$iphone6'>
<input type='hidden' name='imac' value='$imac'>
<input type='submit' value='SEND MAIL' name='submit' ></td>
</tr>
</table>";
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
/* This is what sends the email */
$success = mail($webMaster, $emailsSubject, $body, $headers);
/* Results Rendered as Html */
//echo file_get_contents("http://yourdomain.com/after-message-sent/");
header('location:http://google.com');exit;
?>
使用php重新加载内容 - javascript在对网站进行编程时,我以前使用过此代码,它可以完美工作,但是现在当我想使用一些Flash部件时,每次单击链接时,它都会重新加载所有网站。源代码: <!DOCTYPE html> <html> <head> <title>Hot King Staff</title> <meta charset=…
用jQuery填充模式形式 - javascript我正在将订单表从数据库绘制到datatables(jquery插件)中。我要在每笔最后一笔交易或每笔交易中增加付款。问题是,如何获取单击添加付款按钮以添加付款的行的订单ID。其次,当点击addpayment时,它会弹出一个带有字段或订单号的模态表单。我想用在td中找到的订单ID填充该字段,并使其不可编辑或隐藏,但在提交模态表单时将其发布到服务器。表格和模式表…
尽管刷新,jQuery格式仍未应用于Ajax数据 - javascript我正在通过GET响应消息从服务器(php文件)的可折叠内部加载列表视图。但是,尽管刷新了jQuery元素,但jQuery格式并未应用于添加的HTML。我的页面在这里:http://i.cs.hku.hk/~hsbashir/Project_Work/events/events.htmlHTML代码(仅相关代码)<script> lastRecor…
JavaScript处理期间数组内部的数组 - javascript我正在尝试使用Ajax处理表单,并且在处理复选框时遇到了问题。我以为我可以在数组中做一个数组,将选中的框添加到数据对象中,但这似乎不起作用。它不会显示为控制台中对象的一部分或类似内容。我尝试了一些变化,但没有任何效果。这是当前的样子:var formData = { 'fname' : $('input[name=fname]&…
将简单的javascript代码转换为c# - javascript昨天我在这里问了一个问题。使用javascript和html解决方案很简单前一阵子我打算什么是操纵html来执行javascript中的任务但是我改变了主意,将javascript代码重写为c#这是输入<Abstract> <Heading>Abstract</Heading> <Para TextBreak=…