将从表单接收的客户数据存储为会话:PHP

时间:2017-02-28 21:21:07

标签: php html forms session

我正在尝试将从表单接收的客户数据存储为PHP中的会话。我只是想知道我是否做得对。

表单有三个输入:Name,Email&电话号码+提交按钮

以下是PHP代码和HTML表单。



   <?php


      session_start();
 if (isset($_POST['submit'])) {
 $_SESSION['card-holder-name'] = $_POST['card-holder-name'];
 $_SESSION['Email'] = $_POST['Email'];
 $_SESSION['Phone'] = $_POST['Phone'];

 }
?>
&#13;
    </div>
    <div class="container">
      <form class="form-horizontal" role="form">
        <fieldset>
          <legend>Tell Us About Yourself</legend>

          <div class="form-group"><!--Customers Name-->
            <label class="col-sm-3 control-label" for="card-holder-name">Name</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" name="card-holder-name" id="card-holder-name" placeholder="Card Holder's Name">
            </div>
          </div>
          <div class="form-group"><!--Customers Email-->
            <label class="col-sm-3 control-label" for="Email">Email</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" name="Email" id="Email" placeholder="Email">
            </div>
            </div>
            <div class="form-group"><!--Customers Phone-->
              <label class="col-sm-3 control-label" for="Phone">Phone</label>
              <div class="col-sm-4">
                <input type="text" class="form-control" name="Phone" id="Phone" placeholder="Phone">
              </div>

          </div>


              </div>
            </div>
          </div>
          <div class="form-group"> <!--Submit button-->
            <div class="col-sm-offset-3 col-sm-9">
              <a class="btn btn-success" type="submit" href="Payment_Information." role="button">Checkout</a>

            </div>
          </div>
        </fieldset>
      </form>

     
&#13;
&#13;
&#13;

0 个答案:

没有答案