0

我不确定以前是否有人已经发布过此类问题。我在尝试检查是否已单击提交按钮以及关联表单中的元素是否已存储在变量中时遇到问题。

我有一个计算器表格,它在提交时显示结果;然后动态显示另一个表单。提交第二个表格后,结果会连同来自第二个表格的人名和电子邮件一起通过电子邮件发送给我。我必须使用所有 PHP 作为 HTML 元素,如果不使用 PHP 变量,javascript 元素将无法工作。这是代码示例:

else {
$message0 = "<table style='margin-bottom: 10px; width: 505px;' align='center' border='0' cellpadding='0' cellspacing='0'>
    <tbody>
        <tr valign='top'>
            <td>
                <div style='padding: 0px; margin: 0px; width: 245px; height: 58px;'><a href='http://www.manticoretechnology.com/'><img alt='' src='http://stats.manticoretechnology.com/ImgHost/668/20746/logo.png' border='0' height='52' width='379' /></a>
                </div>
            </td>
            <td align='right' valign='bottom'>
                <div style='font-weight: bold; font-size: 9pt; padding-bottom: 5px; text-transform: uppercase; width: 200px; color: #ef762d; font-family: Arial, Helvetica, sans-serif; text-align: right;'>telecom audit <br />challenge</div>
            </td>
        </tr>
        <tr valign='top'>
            <td colspan='2'>
                <div style='margin: 0px; width: 505px; height: 32px; padding: 0px;'><img alt='' src='http://stats.ManticoreTechnology.com/ImgHost/header.gif' height='32' width='505' />
                </div>
            </td>
        </tr>
        <tr valign='top'>
            <td style='border-right: #e9e9e9 1px solid; border-left: #e9e9e9 1px solid;' colspan='2'>
                <div style='font-size: 8pt; background: #ffffff; width: 503px; color: #666666; line-height: 16px; font-family: Arial, Helvetica, sans-serif;'>
                    <p style='padding-right: 30px; padding-left: 30px; padding-bottom: 20px; margin: 0px; padding-top: 0px;'>This email has been sent to you because someone has filled out the telecom audit calculator. Details of the activity are as follows:</p>
                    <h2 style='padding-right: 0px; padding-left: 0px; font-weight: bold; font-size: 9pt; padding-bottom: 4px; margin: 0px 0px 20px 30px; text-transform: uppercase; width: 75%; color: #14508e; padding-top: 0px; border-bottom: #e9e9e9 1px solid; font-family: Arial, Helvetica, sans-serif;'>Contact Details</h2>
                    <div style='padding-right: 30px; padding-left: 30px; padding-bottom: 20px; margin: 0px; padding-top: 0px;'>
                        <table style='font-size: 8pt; background: #ffffff; color: #666666; line-height: 16px; font-family: Arial, Helvetica, sans-serif;'>
                            <tbody>
                                <tr>
                                    <td style='font-weight: bold;' width='73'>First Name:</td>
                                    <td width='15'></td>
                                    <td width='111'>$fname</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'>Last Name:</td>
                                    <td></td>
                                    <td>$lname</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'>Email:</td>
                                    <td></td>
                                    <td>$email</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'>Landline:</td>
                                    <td></td>
                                    <td>\$ $landline</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'>Long Distance:</td>
                                    <td></td>
                                    <td>\$ $longdist</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'>Wireless:</td>
                                    <td></td>
                                    <td>\$ $wireless</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'>Data:</td>
                                    <td></td>
                                    <td>\$ $data</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'>Conferencing:</td>
                                    <td></td>
                                    <td>\$ $conference</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'><strong>Total Telecom Expense Per Month:</strong>
                                    </td>
                                    <td></td>
                                    <td>\$ $results</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'><strong>Total Telecom Expense Per Year:</strong>
                                    </td>
                                    <td></td>
                                    <td>\$ $yresults</td>
                                </tr>
                                <tr>
                                    <td style='font-weight: bold;'><strong>Estimated Savings:</strong>
                                    </td>
                                    <td></td>
                                    <td>\$ $sevenpercent</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </td>
        </tr>
        <tr valign='top'>
            <td colspan='2'>
                <div style='margin: 0px; width: 505px; height: 32px; padding: 0px;'><img alt='' src='http://stats.ManticoreTechnology.com/ImgHost/footer.gif' height='30' width='505' />
                </div>
            </td>
        </tr>
    </tbody>
</table>
<center>
    <div style='margin: 0px auto; width: 504px; text-align: left;'>
        <p style='padding-right: 15px; padding-left: 15px; font-size: 7pt; padding-bottom: 20px; margin: 0px; color: #999999; padding-top: 0px; font-family: Arial, Helvetica, sans-serif;'>ISI Telemanagement Solutions, Inc., 1051 Perimeter Drive, Suite 200., Schaumburg, IL, 60173, 847-995-0002<br /> This email has been sent to you as part of your Manticore Technology account. Please see your account administrator if you have any questions, or contact your Manticore account representative.</p>
    </div>
</center>";
$formoutput = "<form id='$adminform' class='form-validate' enctype='multipart/form-data' onsubmit='return true' name='$adminform' method='post' action='#' novalidate='novalidate'>
<table width='250px' align='center'>
<tr>
<td class='firstrow_dti' width='39%' align='left'>First Name</td><td class='firstrow_dti' width='14%' align='left'></td>
<td class='firstrow_dti' width='35%' align='left'>Last Name</td>
</tr>
<tr>
<td class='firstrow_dti' width='4%' align='left'>
<input id='fld_18' class='elem18 ' type='text' placeholder='' mask='' value='' name='fld_18' fldname='fname'>
</td>
<td class='firstrow_dti' width='39%' align='left'></td>
<td class='firstrow_dti' width='14%' align='left'>
<input id='fld_19' class='elem19 ' type='text' placeholder='' mask='' value='' name='fld_19' fldname='lname'>
</td>
</tr>
<tr>
<td class='firstrow_dti' width='4%' align='left'></td>
<td class='firstrow_dti' width='39%' height='5' align='left'></td>
<td class='firstrow_dti' width='14%' align='left'></td>
</tr>
<tr>
<td class='firstrow_dti' align='left'>Email</td>
<td class='firstrow_dti' width='39%' align='left'></td>
<td class='firstrow_dti' width='14%' align='left'></td>
</tr>
<tr>
<td class='firstrow_dti' width='4%' align='left'>
<input id='fld_16' class='required elem16 valid' type='text' placeholder='' mask='' value='' name='fld_16' fldname='email'>
</td>
<td class='firstrow_dti' width='39%' align='left'></td>
<td class='firstrow_dti' width='14%' align='left'></td>
</tr>
</table>
<div class='row-fluid2' align='center'>
<div class='btcalctoolbar span12'>
<input id='$submitbutton' class='btn btn-primary' type='button' value='Submit' name='submit'>
<input type='hidden' value='1' name='submitted' />
<input type='hidden' value='' name='postSection'>
<input type='hidden' value='' name='postSection2'>
<input class='btn' type='reset' value='Reset' onclick='javascript:reset$resetbutton;return true;'>
</div>
</div>
</form>";
    $qualify = "<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='30%' valign='top' align='center'><img width='150' height='150' alt='' style='padding-top:100px;' src='/images/badge/congrats-badge.png'></td>
<td width='70%' valign='top' mc:edit='small-image-left-text'>
<p style='font-family:Arial, Helvetica, sans-serif; color:#284C85; font-size:16px; line-height:18px; padding-top:35px;margin-right:45px;'>Congratulations!</p>
<p style='font-family:Arial, Helvetica, sans-serif; color:#333; font-size:12px;color:#333;line-height:18px;margin-right:45px;'>After calculating your telecom needs, we are happy to say that you qualify for our Telecom Savings Challenge.</p>
<p style='font-family:Arial, Helvetica, sans-serif; color:#333; font-size:12px;color:#333;line-height:18px;margin-right:45px;'>If we can't save you <strong style='font-size:13px;'>" . "$" . $sevenpercent . "</strong>, then you'll get a <strong style='font-size:13px;'>$100 gift card</strong>. No Strings attached.</p>
<p><!-- START MODULE - 3 columns -->
<table width='530' border='0' cellpadding='0' cellspacing='0' align='center'>
<tr>
<td width='160' valign='top' align='center'><img src='http://www.isi-info.com/m/campaign/telecom-savings/telecom-challenge-accepted/images/Number-icon-set-1.png' width='32' height='32' /><br><p style='font-family:Arial, Helvetica, sans-serif; color:#333; font-size:12px;color:#333;line-height:18px'>Download and sign <br/>the attached NDA</p><img src='http://www.isi-info.com/m/campaign/telecom-savings/telecom-challenge-accepted/images/download-button.png' width='89' height='23' /></td>


<td width='25' align='center' valign='top'><img src='http://www.isi-info.com/m/assets/divider/content-divider-normal-90-grey.jpg' width='10' height='115'/></td>


<td width='160' valign='top' align='center'><img src='http://www.isi-info.com/m/campaign/telecom-savings/telecom-challenge-accepted/images/Number-icon-set-2.png' width='32' height='32' /><br><p style='font-family:Arial, Helvetica, sans-serif;color:#333;font-size:12px;color:#000000;line-height:18px'>Send us your <br/>telecom invoices</p><img src='http://www.isi-info.com/m/campaign/telecom-savings/telecom-challenge-accepted/images/email-button.png' width='89' height='23' /></td>


<td width='25' align='center' valign='top'><img src='http://www.isi-info.com/m/assets/divider/content-divider-normal-90-grey.jpg' width='10' height='115'/></td>


<td width='160' valign='top' align='center'><img src='http://www.isi-info.com/m/campaign/telecom-savings/telecom-challenge-accepted/images/Number-icon-set-3.png' width='32' height='32' /><br><p style='color:#333; font-family:Arial, Helvetica, sans-serif;font-size:12px;color:#000000;line-height:18px'>We'll review your invoices and provide you with a report</p></td>
</tr>
</table>
<!-- END MODULE - 3 columns --></p>
<p style='font-family:Arial, Helvetica, sans-serif; color:#333; font-size:12px;color:#333;line-height:18px;margin-right:45px;'>So what happens next? Check your registered email for an update on the next step. Basically, after signing a mutual NDA, we will need to review invoices from your most recent full month of billing.</p>
</td>
</tr>
</table>
$formoutput
<div>
</div>
";
if(isset($_POST['submit'])) {
    $to2 = "email@email.com";
    $subject2 = "subject"; 
    mail($to2, $subject2, $message0, $headers);
}
else {
echo "<script language='javascript' type='text/javascript'>
alert('email failed');
</script>";
}
4

1 回答 1

1

如果我理解正确,你需要有代码来接收表单输入——我看到你是通过 POST 发送的。

提交表单后,在表单字段中输入的所有详细信息都将在 POST 变量中(即在 fld_18 输入中输入的任何内容都将在 $_POST['fld_18'] 中找到。)

您是否正在寻找要重新加载的页面?还是在表单提交后将用户发送到另一个页面?

如果您想在不重新加载或将用户发送到另一个页面的情况下显示第二个表单,则使用 JQuery 可能对您更有帮助。

于 2013-07-23T16:11:36.007 回答