codeigniter - 表单未正确提交

时间:2016-03-24 14:35:08

标签: php facebook codeigniter

这是我的视图代码(login.php):

<html>
<head>
    <title>Login with Facebook | Puneet Kalra</title>
</head>
<body>


    <div>

        <form>
            <?php if (@$user_profile):  // call var_dump($user_profile) to view all data ?>
                <div>

                    <?php

                    echo form_open('main/input_data_f');

                        echo "<p> FB ID : ";
                        echo $user_profile['id'];
                        echo "</p>";

                        $this->session->set_userdata(array('fbid' => $user_profile['id']));

                        echo "<p> Email : ";
                        echo form_input('femail');
                        echo "</p>";

                        echo "<p> Password : ";
                        echo form_password('fpass');
                        echo "</p>";

                        echo "<p> Mobile Number : ";
                        echo form_input('fmobile');
                        echo "</p>";

                        echo "<p> Local Address : ";
                        echo form_input('flocal');
                        echo "</p>";

                        echo "<p> City : ";
                        echo form_input('fcity');
                        echo "</p>";

                        echo "<p> State : ";
                        echo form_input('fstate');
                        echo "</p>";

                        echo "<p> Select your Hobbies : ";
                        echo "</p>";

                        echo form_checkbox('fhobby[]' , 'coding' , TRUE);
                        echo "Coding";
                        echo "</p>";

                        echo form_checkbox('fhobby[]' , 'singing' , TRUE);
                        echo "Singing";
                        echo "</p>";

                        echo form_checkbox('fhobby[]' , 'reading' , TRUE);
                        echo "Reading";
                        echo "</p>";

                        echo form_checkbox('fhobby[]' , 'politics' , TRUE);
                        echo "Politics";
                        echo "</p>";

                        echo form_checkbox('fhobby[]' , 'painting' , TRUE);
                        echo "Painting";
                        echo "</p>";

                        echo "Gender : ";
        //echo "</br>";

                        echo form_radio('fgender', 'male', FALSE);
                        echo "Male";
        //echo "</br>";

                        echo form_radio('fgender', 'female', TRUE);
                        echo "Female";
                        echo "</br>";


                        echo form_submit('submit_data_f', 'Complete Registration');
                    echo form_close();
                    ?>
                    </div>
                </div>
            <?php else: ?>
                <h2>Login with Facebook</h2>
                <a href="<?= $login_url ?>" class="btn btn-lg btn-primary btn-block" role="button">Login</a>
            <?php endif; ?>

        </form>


    </div>
</body>
</html>

这是我的控制器代码(main.php):

public function input_data_f()
    {
        $hobby = $this->input->post('fhobby');
        foreach($hobby as $hob)
        {
            $hobbies = $hobbies . "," . $hob;
        }
        $data = array(
            'email' => $this->session->userdata('femail'),
            'password' => md5($this->input->post('fpass')),
            'mobile' => $this->input->post('fmobile'),
            'local' => $this->input->post('flocal'),
            'city' => $this->input->post('fcity'),
            'state' => $this->input->post('fstate'),
            'gender' => $this->session->userdata('fgender'),
            'hobby' => $hobbies,
            'fbid' => $this->session->userdata('fbid')
            );
        $this->load->model('model_register');
        $this->model_register->enter_data($data);   
    }

这是我的模型代码(model_register.php):

public function enter_data($data)
    {
        $this->db->insert('alldata', $data);
        redirect('main/success');
    }

除了视图,一切都是更大文件的一部分。 实际上它是一个登录系统,具有正常登录,谷歌+登录和fb登录。 其余两部分工作正常。 请帮忙!
提前谢谢。

0 个答案:

没有答案