Send data from a modal materialize to the controller

0

I wanted to know in what way I can send the information within a materialize modal, to a controller within the codeigniter framework using php. Thank you in advance.

            Modal

        <!-- Modal Structure -->
        <div id="modal1" class="modal">
            <div class="modal-content">
                    <div class="imgcontainer center">
                        <img src="assets/images/sessionIcon" style="width:100px; height:64px;">
                    </div>
                    <div class="container">
                        <div class="row login center">
                            <h4>LogIn</h4>
                            <div class="row">
                                <div class="input-field col m12 s12">
                                    <i class="material-icons iconis prefix">account_box</i>
                                    <input id="username" type="text" class="validate">
                                    <label for="username">Username</label>
                                </div>
                            </div>
                            <div class="row">
                                <div class="input-field col m12 s12">
                                    <i class="material-icons iconis prefix">enhanced_encryption</i>
                                    <input id="password" type="password" class="validate">
                                    <label for="password">Password</label>
                                </div>
                            </div>
                            <div class="row center">
                                **<button class="btn waves-effect waves-light" type="submit" onclick="<?php echo base_url();?>loginController/ingresar" name="action">Enter</button>**
                            </div>
                        </div>
                    </div>
            </div>
        </div>
    
asked by 31th37 03.07.2018 в 04:26
source

1 answer

0

One option would be to put a form that calls the controller to add the data with a button of type submit.

<!-- Modal Structure -->
        <div id="modal1" class="modal">
            <div class="modal-content">
                    <div class="imgcontainer center">
                        <img src="assets/images/sessionIcon" style="width:100px; height:64px;">
                    </div>
                    <form action="<?php echo base_url();?>loginController/ingresar" method="post">
                    <div class="container">
                        <div class="row login center">
                            <h4>LogIn</h4>
                            <div class="row">
                                <div class="input-field col m12 s12">
                                    <i class="material-icons iconis prefix">account_box</i>
                                    <input id="username" type="text" class="validate">
                                    <label for="username">Username</label>
                                </div>
                            </div>
                            <div class="row">
                                <div class="input-field col m12 s12">
                                    <i class="material-icons iconis prefix">enhanced_encryption</i>
                                    <input id="password" type="password" class="validate">
                                    <label for="password">Password</label>
                                </div>
                            </div>
                            <div class="row center">
                                <button class="btn waves-effect waves-light" type="submit">Enter</button>
                            </div>
                        </div>
                    </div>
                    </form>
            </div>
        </div>

And another, less beautiful option would be to put an onClick that calls a JavaScript function that sends the data to the controller via ajax. But I recommend that you add the data with the form since it is safer.

    
answered by 03.07.2018 в 08:36