简体   繁体   English

如何使用PHP提交网页?

[英]How do I submit a Web page with PHP?

I've created a three step order form and I need help with the third step. 我创建了一个三步订购单,我需要第三步的帮助。 1. form is filled out by the business and clicks on "preview order" 2. business views their order and clicks "confirm" (should be on "bizform.php" but I haven't tried it because I have no clue on how to do it.) 3. by clicking "confirm" the "Web page" or data from "bizform.php" is sent to the business and myself. 1.企业填写表格并单击“预览订单” 2.企业查看其订单并单击“确认”(应该在“ bizform.php”上,但是我没有尝试过,因为我不知道如何3.单击“确认”,将“网页”或“ bizform.php”中的数据发送给企业和我本人。

Questions: Is it possible? 问题:可能吗? If so, can you point me in the right direction? 如果是这样,您能指出我正确的方向吗? TYVM TYVM

My form: 我的表格:

    <div class="span4 diff">
    <h3>Business Information</h3>
    <br/>
    <form action="bizform.php" method="post">
    <label for="bizName" class="control-label">
    Business:</label>
    <input type="text" id="bizName" name="bizName" class="input-large">

    <label for="bizAddress" class="control-label">
    Business Address:</label>
    <input type="text" id="bizAddress" name="bizAddress" class="input-large">

    <label for="bizCity" class="control-label">
    City:</label>
    <input type="text" id="bizCity" name="bizCity" class="input-large">

    <label for="bizState" class="control-label">
    State:</label>
    <input type="text" id="bizState" name="bizState" class="input-large">

    <label for="bizZip" class="control-label">
    Zip code:</label>
    <input type="text" id="bizZip" name="bizZip" class="input-large">

    <label for="fullName" class="control-label">
    Full Name:</label>
    <input type="text" id="fullName" name="fullName" class="input-large">

    <label for="bizEmail" class="control-label">
    E-mail:</label>
    <input type="text" id="bizEmail" name="bizEmail" class="input-large">
    </div>
    <div class="span7">
    <h3>Choose Products</h3>
    <br/>
    <table class="table table-bordered table-striped">
    <thead>
    <tr class="diffhead">
    <th>Product</th>
    <th>Price</th>
    <th>Training</th>
    <th>Total</th>
    <th>Qty</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>Product One</td>
    <td>$1000.00</td>
    <td>$100.00</td>
    <td>$1100.00</td>
    <td>
    <label class="input" for="productOne"></label>
    <input type="text" class="input-mini" value="0" id="productOne" name="productOne">
    </td>
    </tr>
    <tr>
    <td>Product Two</td>
    <td>$1000.00</td>
    <td>$100.00</td>
    <td>$1100.00</td>
    <td>
    <label class="input" for="productTwo"></label>
    <input type="text" class="input-mini" value="0" id="productTwo" name="productTwo">
    </td>
    </tr>
    <tr>
    <td>Product Three</td>
    <td>$1000.00</td>
    <td>$100.00</td>
    <td>$1100.00</td>
    <td>
    <label class="input" for="productThree"></label>
    <input type="text" class="input-mini" value="0" id="productThree" name="productThree">
    </td>
    </tr>
    </tbody>
    </table>
    </div>
    </div>
    <div class="form-actions">
    <button class="btn btn-danger" type="reset" style="float:left">
    <i class="icon-remove-sign icon-white"></i> Cancel Order</button>
    <button class="btn btn-primary" type="submit" style="float:right">Preview Order 
    <i class="icon-circle-arrow-right icon-white"></i></button>
    </form>
    <?php
    include '_inc/footer.html';
    ?>

My form processor: 我的表格处理器:

        <?php
    include '_inc/header.html';
    ?>
    <?php 

    $bizName = $_POST['bizName'];
    $bizAddress = $_POST['bizAddress'];
    $bizCity = $_POST['bizCity'];
    $bizState = $_POST['bizState'];
    $bizZip = $_POST['bizZip'];
    $fullName = $_POST['fullName'];
    $bizEmail = $_POST['bizEmail'];

    $productOne = $_POST['productOne'];
    $productTwo = $_POST['productTwo'];
    $productThree = $_POST['productThree'];


    $moneyOff = '';

    $totalPro = $productOne + $productTwo + $productThree;

    define('PRODPRICE', 1100);

    $totalMoney = $productOne * PRODPRICE
    + $productTwo * PRODPRICE
    + $productThree * PRODPRICE;

    if ( $totalMoney == 2200 )
    {
    echo '<div class="alert alert-success">Go Back! You can get a product for free!</div>';
    }

    if ( $totalMoney == 3300 )
    {
    $moneyOff = 1100;
    }
    else
    {
    $moneyOff = 0;
    }


    define('STOCKFEE', 10);
    $stockFee = $productOne * STOCKFEE
    + $productTwo * STOCKFEE
    + $productThree * STOCKFEE;

    ?>
    <h1 align="center">Order Agreement</h1>
    <br/>
    <?php 
    echo '<strong>' .$bizName. '</strong> is purchasing the following products and services from CBE:</p>';
    echo '<div class="well">
    <table cellspacing="0" cellpadding="0" width="800px">
    <thead>
    <th>Qty</th>
    <th>Product</th>
    <th>Price</th>
    </thead>
    <tbody>
    <tr>
    <td align="center">'. $productOne .'</td>
    <td align="center">Product One</td>
    <td align="center">$1,100.00</td>
    </tr>
    <tr>
    <td align="center">'. $productTwo .'</td>
    <td align="center">Product Two</td>
    <td align="center">$1,100.00</td>
    </tr>
    <tr>
    <td align="center">'. $productThree .'</td>
    <td align="center">Product Three</td>
    <td align="center">$1,100.00</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td align="right">Sub Total:</td>
    <td align="center">'.number_format($totalMoney,2).'</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td align="right">Discount:</td>
    <td align="center">'.number_format($moneyOff,2).'</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td align="right">Grand Total:</td>
    <td align="center">'.number_format($totalMoney - $moneyOff,2).'</td>
    </tr>
    </tbody>
    </table>
    </div>';
    echo '<p>Business agrees to pay <strong> '.number_format($totalMoney - $moneyOff,2).' </strong>for these products and services. In addition, Business will pay an additional <strong> '.number_format($stockFee,2).' </strong>to cover stock fee.</p>';
    ?>
    <div class="row">&nbsp;</div>
    <div class="row">
    <div align="left">
    <table cellspacing="10" cellpadding="10" width="850px">
    <tbody>
    <tr><td>&nbsp;</td></tr>
    <tr>
    <td valign="top">
    <?php 
    echo '<strong>' .$bizName. '</strong> <br/>';
    echo $bizAddress.'<br/>';
    echo $bizCity.', ';
    echo $bizState.' ';
    echo $bizZip.'';
    ?>
    </td>
    <td valign="top">
    <strong>CBE</strong><br/>
    Corporate Headquarters<br/>
    555 Main Street<br/>
    PHPLAND, DB 78987-3849<br/>
    888-098-3049
    </td>
    </tr>
    </tbody>
    </table>
    </div>
    </div>
    <?php
    include '_inc/footer.html';
    ?>

When you submit the form to bizform.php, store you post variables in hidden input fields, and submit those to your form processor on step 3. 将表单提交到bizform.php时,将变量存储在隐藏的输入字段中,然后在步骤3上将其提交给表单处理器。

EDIT: 编辑:

In other words, have your Confirm process post your hidden fields to another processor that creates your email content from the POST, and send TO the business, and yourself as a CC or BCC header. 换句话说,让您的Confirm流程将您的隐藏字段发布到另一个处理器,该处理器从POST创建您的电子邮件内容,并以CC或BCC标头的形式发送给企业和您自己。

<input name="AID" type="hidden" id="AID" value="<?php echo $_POST['AID']; ?>" size="32" />

由于您可以通过$ _POST数组轻松访问数据,因此要将所有这些信息发送给相应的接收者,请使用php的mail()函数来创建电子邮件并将其发送给您想要的任何人。

To store the the data across multiple forms: 要以多种形式存储数据:

<?php
  session_start(); // Initiates the session, and loads the _SESSION variable

  var_dump($_SESSION); // Show the data in the _SESSION variable

  // Load data into the sessions
  $_SESSION['a'] = 1;
  $_SESSION['b'] = 'hello world';

  if (!isset($_SESSION['c'])) $_SESSION['c'] = 0;
  else $_SESSION['c'] += 2;

At first, you should see an empty array. 首先,您应该看到一个空数组。 Then, refresh and you will see your session data. 然后,刷新,您将看到您的会话数据。

http://php.net/manual/en/features.sessions.php - for reference and further education... http://php.net/manual/zh/features.sessions.php-供参考和进一步的教育...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM