0

我正处于一个我已经工作了大约 2 周的项目的最后阶段。我的 HTML 表单已创建并在功能上与 PHP 完全兼容。目前,在提交表单后,它会回显结果。在这一点上,我不知道下一步该去哪里。

我希望能够从该页面获取信息,并添加数字数字签名(很像 PIN)并使用 PHP 将最终结果提交到电子邮件中。

我可以分别做这两个。IE - 我可以创建一个表单来回显结果,我可以创建一个立即通过电子邮件发送结果的表单,但我不明白如何将它们结合起来。

如何在添加数字签名的同时将表单的回显结果作为电子邮件提交?

(由于我没有提供代码,因为我对 PHP 很陌生,我不希望任何人为我做这件事,但我很难通过谷歌搜索找到相关信息,所以即使指向我的权利方向会非常有帮助。)

谢谢

现在我知道得更多了。所有代码:

HTML

<form action="echo_form_email.php" method="GET">

<p>
<div id="cheddar">Cashier: <input id="cashier" name="cashier" type="text"></div> 
</p>

<P>
<div id="q">Did the cashier front the register?</div>
<div id="radio1"><input type="checkbox" name="front_register" value="Yes">Yes</div> 
    <div id="radio2"><input type="checkbox" name="front_register" value="No">No</div> 
<div id="radio3"><input type="checkbox" name="front_register" value="N/A">N/A</div>
</p>

<p>
<div id="q">Genuinely greet customer with eye contact?</div>
<div id="radio1"><input type="checkbox" name="greets" value="Yes">Yes</div> 
<div id="radio2"><input type="checkbox" name="greets" value="No">No</div> 
</p>

<p>
<div id="q">Scan/unload B.O.B. (If no bagger)</div>
<div id="radio1"><input type="checkbox" name="scan_bob" value="Yes">Yes</div> 
<div id="radio2"><input type="checkbox" name="scan_bob" value="No">No</div> 
<div id="radio3"><input type="checkbox" name="scan_bob" value="N/A">N/A</div>
</p>

<p>
<div id="q">Carry conversation around product in basket or genuine conversation?</div>
<div id="radio1"><input type="checkbox" name="conversation" value="Yes">Yes</div> 
<div id="radio2"><input type="checkbox" name="conversation" value="No">No</div> 
<div id="radio3"><input type="checkbox" name="conversation" value="N/A">N/A</div>
</p>

<p>
<div id="q">Offer buddy bucks to parent at beginning of order?</div>
<div id="radio1"><input type="checkbox" name="buddy" value="Yes">Yes</div> 
<div id="radio2"><input type="checkbox" name="buddy" value="No">No</div> 
<div id="radio3"><input type="checkbox" name="buddy" value="N/A">N/A</div> 
</p>

<p>
<div id="q">Avoid side conversations?</div>
<div id="radio1"><input type="checkbox" name="side_conversation" value="Yes">Yes</div> 
<div id="radio2"><input type="checkbox" name="side_conversation" value="No">No</div> 
</p>

<p>
<div id="q">Point out and circle savings?</div>
<div id="radio1"><input type="checkbox" name="savings" value="Yes">Yes</div> 
<div id="radio2"><input type="checkbox" name="savings" value="No">No</div> 
<div id="radio3"><input type="checkbox" name="savings" value="N/A">N/A</div>
</p>

<p>
<div id="q">Offer carryout (if no bagger)?</div>
<div id="radio1"><input type="checkbox" name="carry_out" value="Yes">Yes</div> 
<div id="radio2"><input type="checkbox" name="carry_out" value="No">No</div> 
<div id="radio3"><input type="checkbox" name="carry_out" value="N/A">N/A</div>
</p>

<p>
<div id="q">Give a genuine "thank you"?</div>
<div id="radio1"><input type="checkbox" name="thanks" value="Yes">Yes</div> 
<div id="radio2"><input type="checkbox" name="thanks" value="No">No</div> 
</p>

<p>
<div id="cheddar">Digital Signature</div>
<div id="cheddar"><input type="tel" name="sign1" placeholder="Peoplesoft ID"></div>
</p>

<p>
<div id="auditingasm">ASM performing audit: <br />
<select name="asm">
<option value="John Doe">John Doe</option>
<option value="Jane Doe">Jane Doe</option>
<option value="Little Doe">Little Doe</option>
<option value="Big Doe">Big Doe</option>
</select></div>
</p>

<br />
<input type="submit" value="submit" name="submit">
<input id="reset" type="reset">
</form>

PHP 表单回显

<?PHP
if (! empty($_GET['cashier'])){
   echo 'Cashier receiving audit: ' . $_GET['cashier'];
}
echo "<br />";
if (! empty($_GET['asm'])){
   echo 'ASM performing audit: ' . $_GET['asm'];
}
echo "<br /><Br />";
if (! empty($_GET['front_register'])){
   echo 'Did cashier front the register? ' . $_GET['front_register'];
}
echo "<br />";
if (! empty($_GET['greets'])){
   echo 'Greet customer with eye contact? ' . $_GET['greets'];
}
echo "<br />";
if (! empty($_GET['scan_bob'])){
   echo 'Scan/Unload BOB (if no bagger) ' . $_GET['scan_bob'];
}
echo "<br />";
if (! empty($_GET['conversation'])){
   echo 'Conversation about groceries, or other genuine conversation? ' .     $_GET['conversation'];
}
echo "<br />";
if (! empty($_GET['buddy'])){
   echo 'Offer Buddy bucks to parent at beginning of order? ' . $_GET['buddy'];
}
echo "<br />";
if (! empty($_GET['side_conversation'])){
   echo 'No side conversations? ' . $_GET['side_conversation'];
}
echo "<br />";
if (! empty($_GET['savings'])){
   echo 'Cashier pointed to and circled savings? ' . $_GET['savings'];
}
echo "<br />";
if (! empty($_GET['carry_out'])){
   echo 'Offered carry out (if no bagger) ' . $_GET['carry_out'];
}
echo "<br />";
if (! empty($_GET['thanks'])){
   echo 'Genuine "thank you?" ' . $_GET['thanks'];
}
echo "<br /><Br />";
if (! empty($_GET['sign1'])){
   echo 'Digital Signature: ' . $_GET['sign1'];
}
?>

PHP 表单电子邮件

这是附加到表单的原始 php,它通过电子邮件发送到正确的地址以使表单可打印。这个之前的代码是用于回声的 PHP,正如 @Death 今天早些时候在另一个论坛上看到的那样。
<?
//---------------
// Cashier Audit
//---------------
$msg .= "Cashier being audited: ".$_POST["cashier"]."";
$msg .= "\n\nFront the register? $front_register\n";
$msg .= "Greet customer with eye contact? $greets\n";
$msg .= "Scan/Unload BOB (if no bagger) $scan_bob\n";
$msg .= "Conversation about groceries, or other genuine conversation? $conversation\n";
$msg .= "Offer Buddy bucks to parent at beginning of order? $buddy\n";
$msg .= "No Side Conversations? $side_conversation\n";
$msg .= "Cashier pointed to and circled savings? $savings\n";
$msg .= "Offered carry out (if no bagger)? $carry_out\n";
$msg .= "Genuine Thank You? $thanks\n\n";
$msg .= "**************************************************************\n";
$msg .= "\n\n\nCashier signature:__________________________";
$msg .= "\n                             $cashier";
$msg .= "\n\n\n\n\nASM signature:__________________________";
$msg .= "\n                         $asm";

//-----------------
// Signature Lines
//-----------------
.= $checkbox=$_POST['checkbox'];
.= $asm = $_POST['asm'];

$to = "email@address.com";
$from = "other@email.com";
$subject = "Service Audit";
$mailheaders = "From: \"$asm\" <$from> . \n";
//$mailheaders .= "Reply-To: $from\n\n";

mail($to, $subject, $msg, $mailheaders);

?>
4

2 回答 2

0

在不知道项目范围的情况下很难提供“答案”,但您可能会发现此函数在 PHP 中很有帮助:

$output = file_get_contents($url);

你总是可以在后面添加东西,所以如果上面$url是回显结果的文件,你可以在最后添加一些东西,比如:

$output .= $signature

然后只需通过电子邮件将 $output 作为正文或其他内容

于 2013-08-13T03:07:35.860 回答
0

如果我理解正确,您有一个 HTML 表单并希望:

  1. 在 HTML/PHP 表单上审核员工 ( audit.php)

  2. 将该审核的结果发布到另一个 PHP 页面/表单 ( audit_confirm.php)

  3. 员工输入他们的 ID audit_confirm.php,然后有人点击“提交”

  4. 信息以电子邮件形式发送

审核表 [audit.php]

您的第一个页面/表单将数据发布到确认页面,因此将表单标签的 action 属性更改为 post 到audit_confirm.phpie

<form action="audit_confirm.php" method="post">
<!-- all your existing form data-->
</form>

审核确认表 [audit_confirm.php]

audit_confirm.php将创建以下逻辑:

  1. 显示审计结果
  2. 提供包含文本框的确认表单,让员工可以输入他们的 ID
  3. 将此信息发布到同一页面并捕获 POST 数据(可以使用隐藏的表单元素来分割表单逻辑流)
  4. 发送包含审计数据的电子邮件
  5. 重定向到您的audit.php页面,以便您可以执行另一次审核

用这个替换你现在调用的内容PHP Form Echo

<?php

    switch(true)
    {
        case ($_POST['employee_id_confirm'] == true):

            //---------------
            // Cashier Audit
            //---------------
            $msg .= "Cashier being audited: ".$_POST['cashier']."";
            $msg .= "\n\nFront the register? ".$_POST['front_register']."\n";
            $msg .= "Greet customer with eye contact? ".$_POST['greets']."\n";
            $msg .= "Scan/Unload BOB (if no bagger) ".$_POST['scan_bob']."\n";
            $msg .= "Conversation about groceries, or other genuine conversation? ".$_POST['conversation']."\n";
            $msg .= "Offer Buddy bucks to parent at beginning of order? ".$_POST['buddy']."\n";
            $msg .= "No Side Conversations? ".$_POST['side_conversation']."\n";
            $msg .= "Cashier pointed to and circled savings? ".$_POST['savings']."\n";
            $msg .= "Offered carry out (if no bagger)? ".$_POST['carry_out']."\n";
            $msg .= "Genuine Thank You? ".$_POST['thanks']."\n\n";
            $msg .= "**************************************************************\n\n\n\n\n";
            $msg .= "Cashier signature:        ".$signature."\n";
            $msg .= "                     _______________________________";
            $msg .= "\n                     $cashier";
            $msg .= "\n\n\n\n\n";
            $msg .= "ASM signature:            ".$asm."\n";
            $msg .= "                     ________________________________";
            $msg .= "\n                         $asm";

            $to = "email@address.com";
            $from = "other@email.com";
            $subject = "Service Audit";
            $mailheaders = "From: \"".$asm."\" <".$from.">\r\n".
            "Reply-To: noreply@yourdomain.com\r\n".
            "X-Mailer: PHP/". phpversion();
            mail($to, $subject, $msg, $mailheaders);

            //redirect to audit.php
            header("Location:audit.php");
            exit();
            break;
    }

    //form data from audit.php
    $get_data_meta_arr = array(
        'cashier' => 'Cashier receiving audit:',
        'asm' => 'ASM performing audit:',
        'front_register' => 'Did cashier front the register?',
        'greets' => 'Greet customer with eye contact?',
        'scan_bob' => 'Scan/Unload BOB (if no bagger)',
        'conversation' => 'Conversation about groceries, or other genuine conversation?',
        'buddy' => 'Offer Buddy bucks to parent at beginning of order?',
        'side_conversation' => 'No side conversations?',
        'savings' => 'Cashier pointed to and circled savings?',
        'carry_out' => 'Offered carry out (if no bagger)',
        'thanks' => 'Genuine "thank you?"'  
    );

?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Info Confirm</title>
</head>
<body>
    <div id="view-info">
        <h2>Audit Confirmation</h2>
    </div>
    <div id="form-confirm">
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
            <div class="field-hidden">
                <input type="hidden" name="employee_id_confirm" value="true">                    
            </div>
            <div class="echo">
                <?php
                foreach($get_data_meta_arr as $key => $value)
                {
                    $audit_question_str = $value;           //the audit question
                    $audit_result_str = $_GET[$key];        //the audit result              
                ?>
                <p><?php echo $audit_question_str.': '.$audit_result_str; ?></p>
                <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $audit_result_str; ?>">
                <?php
                }
                ?>
            </div>
            <div class="field">
                <label for="employee_id">Employee ID</label>
                <input id="employee_id" type="text" name="signature" maxlength="40">
            </div>
            <div class="action">
                <input type="submit" value="Confirm">
            </div>
        </form>
    </div>
</body>
</html>

您可以取消,PHP Form Email因为电子邮件消息功能内置于上述代码中。

我希望这有帮助。

于 2013-08-13T03:26:08.190 回答