php表单的问题

时间:2014-02-14 13:10:02

标签: php html forms

我正在尝试填写表格。

我希望有人在下面填写信息 t1.html

在他们填写信息后,他们会看到谢谢你的提交 (现在它转到他们输入的php页面)

有人会收到一封电子邮件(电子邮件地址为电子邮件地址在表单中),其中包含一个php页面链接,其中包含从表单输入的内容。

获得该电子邮件的人将接受或拒绝该php页面。

我错过了如何生成php页面,因此接收电子邮件的人将能够访问输入到表单中的内容的信息。我该怎么做?

形式

    <form name="iform" method="post" action="html_form1.php" class="iform">

    <ul>

    <li><label for="SendingeWarrant">Sending  to:</label><input class="itext"         type="text" name="SendingeWarrant" id="SendingeWarrant" /></li>
    <li class="iseparator">&nbsp;</li>
    <li>
    <label for="Email">Email Address  that the email goes to:</label><input   class="itext" type="text" name="Email" id="Email" />
    </li>
    <li class="iseparator">&nbsp;</li>
    <li><label>&nbsp;</label><input type="Submit" name="Submit" value="Submit" /></li>
    </ul></form>

PHP

     <?php
     if (!empty($_POST)) {


$success = $error = false;


$post = new stdClass;


foreach ($_POST as $key => $val)
    $post->$key = trim(strip_tags($_POST[$key]));

// Check for blank fields
if ( empty($post->Email))
    $error = true;

else {

    // Get this directory, to include other files from
    $dir = dirname(__FILE__);

    // Get the contents of the pdf into a variable for later
    ob_start();
    require_once($dir.'/pdf.php');
    $pdf_html = ob_get_contents();
    ob_end_clean();

    // Load the dompdf files
    require_once($dir.'/dompdf/dompdf_config.inc.php');

    $dompdf = new DOMPDF(); // Create new instance of dompdf
    $dompdf->load_html($pdf_html); // Load the html
    $dompdf->render(); // Parse the html, convert to PDF
    $pdf_content = $dompdf->output(); // Put contents of pdf into variable for   later

    // Get the contents of the HTML email into a variable for later
    ob_start();
    require_once($dir.'/html3.php');
    $html_message = ob_get_contents();
    ob_end_clean();

    // Load the SwiftMailer files
    require_once($dir.'/swift/swift_required.php');

    $mailer = new Swift_Mailer(new Swift_MailTransport()); // Create new instance of SwiftMailer

    $message = Swift_Message::newInstance()
                   ->setSubject('eWarrant') // Message subject
                   ->setTo(array($post->Email => $post- >SendingeWarrant)) // Array of people to send to
                   ->setFrom(array('no-reply@henschen.com' =>  'eWarrant')) // From:
                   ->setBody($html_message, 'text/html'); // Attach  that HTML message from earlier


    // Send the email, and show user message
    if ($mailer->send($message))
        $success = true;
    else
        $error = true;

  }

      }
      ?>


     <html>
        <head>
<style>
body {font-family:Helvetica, Arial, sans-serif; font-size:10pt;}
table {width:100%; border-collapse:collapse; border:1px solid #CCC;}
td {padding:5px; border:1px solid #CCC; border-width:1px 0;}
</style>
    </head>
       <body>

<h1></h1>

<table>
    <tr>
        <td><strong>Name of person sending to:</strong></td>
        <td><?php echo $_POST["SendingeWarrant"]; ?></td>
        <td><strong>Email being sent to:</strong></td>
        <td><?php echo $_POST["Email"]; ?></td>
    </tr>
</table>

<p>Approve / Deny</p>

    </body>
    </html>
    </body>
    </html>

电子邮件php文件

    <html>
    <body>

    <p style="font-family:Helvetica, Arial, sans-serif;font-size:"x-small";"><?php echo   $post->SendingeWarrant; ?></p>
      <p style="font-family:Helvetica, Arial, sans-serif;font-size:"x-small";">Click  link to approve or deny:  </p>

    </body>
      </html>

1 个答案:

答案 0 :(得分:0)

在您的数据库中输入电子邮件数据,当接收电子邮件的人员点击接受按钮时,它将从数据库中获取该数据。