如何在会话中传递表单字段值,并在CakePHP中的DIV标签中显示



谢谢,实际上,我有一个表格,带有考试名称,场地,考试日期,价格/课程,考试数量,并添加到购物车提交按钮,以下我有一个<div id="division"></div>。在表单字段中输入详细信息并提交表单后,表单字段值应传递到以下<div id="division"></div>标签。对于表单的每个条目,值应添加到<div id="division"></div>标签中。我想删除我之前添加的项目。我可以使用CakePHP中的会话来进行此操作。例如,在购物车中的购物车中添加物品。

My index.ctp view page
   <table><thead>
          <th>Exam Name</th>
          <th>Venue Name</th>
          <th>Date of Exam</th>
          <!--<th>Documents</th> --> 
          <th>Price / Course</th>  
          <th>Number of Exams</th>
          <th style="display:none">Document</th>  
          <th>Add to Cart</th> 
         </thead>
         <tbody>
          <tr>
    <form name="cartTable" id="cartTable" method="post" action="<?php echo $this->webroot ?>users/cartData/?>">  
             <td><?php echo $k; ?></td> 
              <td id="examCart">
              <span id="errname"></span>
              <select name="course" id="course" required="required">  
                <option value="">--Select--</option>
                <!--<option>Prince 2 Foundation</option>
                <option>Prince 2 Practitioner</option>
                <option>ITIL Foundation</option> 
                <option>COBIT Foundation</option> -->
                <?php foreach($userexams as $userexam):
                    $cmbExams = $userexam['exams']['exam'];      
                    $newtest = explode(',',$cmbExams);                
                    for($i=0;$i<count($newtest);$i++) 
                    {
                    ?>
                 <option value="<?php echo $newtest[$i];?>"><?php echo $newtest[$i];?></option>
                <?php 
                    }
                   endforeach; ?>
              </select>           
              </td>    
              <td id="examvenue"><span id="errVenue"></span><input type="text" name="venue" id="venue" required="required"></td>        
          <td><span id="errDate"></span><input type="text" name="Userdate" id="Userdate" required="required"></td>
           <!--<td><?php //echo $alldata['e']['document']; ?></td>-->
           <td id="priceCart"><?php echo "$0"; //echo "$0 ".$alldata['e']['price']; ?></td> 
           <td>
              <span id="errNoExam"></span>
              <select required="required" class="create-user" name="data[Exam][orderexam]" id="orderCart" onchange="change()">
               <option value="">-- Select --</option>                      
              <?php
                 for($i=1;$i<=10000;$i++)  
                 {
              ?> 
              <option value="<?php echo $i; ?>"><?php echo $i; ?></option>                    
             <?php } ?>          
           </td>
           <td style="display:none"><input type="text" name="hide" value="<?php echo $alldata['e']['document']?>"></td>
           <td><input type="submit" name="btnAddCart" value="Add to Cart" class="cartbtn"><!--<button type="button" class="btn btn-success btn-xs cartbtn">Add to Cart</button>--></td> 
           </form>
         </tr></tbody>
    <div class="container cartdetails"> 
       <div class="row"> 
        <div class="col-md-10">
         <p style="font-size:25px;text-align:center;">Cart Details</p> 
           <div id="division">
       ////// I Have to pass the session values here ///////    
           </div>
        <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
          <input type="hidden" name="cmd" value="_cart">
          <input type="hidden" name="business" value="ragith.thomas@yahoo.com"> 
          <input type="hidden" name="upload" value="1">
            <input type="hidden" name="item_number_" value="" id="itm_no">    
            <input type="hidden" name="item_name_" value="" id="item_name">   
            <input type="hidden" name="amount_" value="" id="eprice"> 
            <input type="hidden" name="shipping_" value="sdssddd" >  
            <input type="hidden" name="quantity_" value="3" id="eorder"> 
          <input type="hidden" name="currency_code" value="USD" >     
          <input type="hidden" name="amount" value="" id="payTotal">  
          <!--<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" id="placeOrder"> -->
        </form>
    </div>
    </div>
    </div>
    My UsersController.php page code as below
    <?php
    App::uses('CakeEmail', 'Network/Email');
    class UsersController extends AppController
    {
       public function cartData() 
       {

        }
    }

您的问题非常广泛,并且代码看起来不明显。在CakePHP中,您应该使用表格助手来构建表单(http://book.cakephp.org/3.0/en/views/helpers/form.html)并发布数据,然后在控制器操作中处理该数据并使用会话对象存储数据(http://book.cakephp.org/3.0/en/development/sessions.html#accessing-the-session-object)

相关内容

最新更新