使用多种表格注册



我正在使用Laravel,在我的网站上我需要进行多次注册。第一个视图是用户输入自己的信息和个人资料图片,第二个视图是选择账户类型,第三个视图是用Paypal支付铭文费用。我想通过使用Input::all()获得最终视图中的所有信息,我希望有一种简单的方法来实现

我自己解决了这个问题,创建了一个php类来存储所有这些数据,然后创建这个类的对象并将其存储在会话中。

class data{
    public $data1;
    public $data2;
    public $data3;
    //must checks if the data is complete
    function checkdata(){
        if(condition){
            return true;
        }else{
            return false;
        }
    }
}
//Store data in session or load existing data from session.
if(isset($_SESSION["data"]){
    $data = $_SESSION["data"];
}else{
    $data = new data();
    $_SESSION["data"] = $data;
}
//do with the data whatever needs to be done. change the variables if needed etc.
$data->$data1 = $_POST["data1"];
//once all data is complete send and save it where it needs to be saved and unset the session
if($data->checkdata()){
    saveorsenddata($data);
    unset($_SESSION["data"]);
}//else do nothing

最新更新