在codeigniter中的多页表单,并在每个步骤验证后将数据保存在数据库中

时间:2015-01-08 02:30:09

标签: php sql codeigniter multi-step

我正在构建多页面表单,我希望每个部分在用户点击“下一步”后验证并提交给数据库,这是最好的方法...我已将整个表单写在一个页面中并想要保存用户单击“下一步”后在数据库中,但是对于此下一个按钮,我没有写入类型=“提交”,所以如何将数据传递给控制器​​
这个视图,它在多步骤中显示表单,任何人都可以了解如何在db中保存

<div class="container">
<div class="stepwizard">
    <div class="stepwizard-row setup-panel" >
        <div class="stepwizard-step">
            <a href="#step-1" type="button" class="btn btn-primary btn-circle">1</a>
            <p>Step 1</p>
        </div>
        <div class="stepwizard-step">
            <a href="#step-2" type="button" class="btn btn-default btn-circle" disabled="disabled">2</a>
            <p>Step 2</p>
        </div>
        <div class="stepwizard-step">
            <a href="#step-3" type="button" class="btn btn-default btn-circle" disabled="disabled">3</a>
            <p>Step 3</p>
        </div>
    </div>
</div>
<form role="form">
    <div class="row setup-content" id="step-1">
        <div class="col-xs-12">
            <div class="col-md-12">
               <div class="video-container">
            <iframe width="300" height="168" src="" frameborder="0" allowfullscreen></iframe>
            </div>
                <button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Next</button>
            </div>
        </div>
    </div>
    <div class="row setup-content" id="step-2">
        <div class="col-xs-12">
            <div class="col-md-12">
                <h3> Step 2</h3>
                <div class="form-group">
                    <table class="table table-striped b-t b-light text-sm">
                         <tr>
                        <td> <a href="<?php echo site_url("user/register") ?>" > New User  ?? </a> </td>
                        </tr>
                        <tr>
                        <th>  Email </th>
                        <td><input type="text" name="email" /> </br> </br></td>
                        </tr>
                        <tr>
                        <th>  Password </th>
                        <td> <input type="password" name="password" /> </td>
                        </tr>
                        <tr>
                        <th></th>
                        <td> <input type="submit" name="login" value="Sign in" />  </td>
                        <td></td>
                        </tr> 
                    </table>
                </div>
                <button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Next</button>
            </div>
        </div>
    </div>
    <div class="row setup-content" id="step-3">
        <div class="col-xs-12">
            <div class="col-md-12">
                <h3> Step 3</h3>
                <button class="btn btn-success btn-lg pull-right" type="button">Finish!</button>
            </div>
        </div>
    </div>
</form>
</div>

1 个答案:

答案 0 :(得分:2)

你好,你尝试这个jquery步骤插件,我可以帮助你解决你的问题,首先验证然后进入下一步,最后提交所有数据的完整表格。检查示例

http://www.jquery-steps.com/Examples