Jump to content

putting user input from multistep, multiform modal in db


Recommended Posts

Hello, everyone! 

I have a multistep modal taken from here. I have input fields, checkboxes and dropdowns. Also I have put the product attributes code in the modal, so the user can select them from inside. I have made every step of the 3-rd modal in the link to be a form. Each "Continue" button is type submit and I use the preventDefault function, so that the page doesn't reload and the modal doesn't close. The last step has to be an overview, so that the user can see if they entered some info wrong and can go back and fix it. On the overview step there is a button, which sends the info as an email.
At first I tried to take the input from the session, but this did not work for me. I have since decided to collect the user input in the db, so that I can always call and use it as I need.

The problem is that I do not know how to put the user input in the db. If someone can help me with this OR tell me another way to collect the variables from the submits and display them in the overview I will be really grateful!

here is an example snippet from my php file: 
 

    public function hookDisplayReassurance()
    {    
	$_SESSION["customer_name_reservation"] = Tools::getValue('customer_name_reservation');
        $_SESSION["customer_mail_reservation"] =Tools::getValue('customer_mail_reservation');
        $_SESSION["customer_phone_reservation"] =Tools::getValue('customer_phone_reservation');

        $customer_name_reservation = $_SESSION["customer_name_reservation"];
        $customer_mail_reservation = $_SESSION["customer_mail_reservation"];
        $customer_phone_reservation = $_SESSION["customer_phone_reservation"];

	$this->smarty->assign('customer_name_reservation', $customer_name_reservation);
        $this->smarty->assign('customer_mail_reservation', $customer_mail_reservation);
        $this->smarty->assign('customer_phone_reservation', $customer_phone_reservation);

	return $this->display(__FILE__, 'views/templates/front/test.tpl');
	}

and an example snippet from the tpl:
 

                {*Third step*}
                <form>
                <div id="third-step" class="modal-body step-3" data-step="3">
                    <h2>Customer data</h2><br>
                    <label style="color: #9F2211; font-weight: 900;">* </label><label
                            for="recipient-name" class="col-form-label">Full name:</label>
                    <input type="text" name="customer_name_reservation" value="{$customer_name_reservation}"
                           class="form-control" required>
                    <label style="color: #9F2211; font-weight: 900;">* </label><label
                            for="recipient-mail" class="col-form-label">E-mail:</label>
                    <input type="email" name="customer_mail_reservation" value="{$customer_mail_reservation}"
                           class="form-control" required>
                    <label style="color: #9F2211; font-weight: 900;">* </label><label
                            for="recipient-name" class="col-form-label">Phone:</label>
                    <input type="tel" name="customer_phone_reservation" value="{$customer_phone_reservation}"
                           class="form-control" required>
                </div>
                </form>

                <form>
                <div id="fifth-step" class="modal-body step-5" data-step="5">
                    <div class="modal-body step step-5">
                        <label>Full name: </label>
                        <label>{$customer_name_reservation}</label>
                        <input name="customer_name_reservation" value="{$customer_name_reservation}" readonly
                               style="border:none; outline: none;"><br>
                        <label>Phone: </label>
                        <input name="customer_phone_reservation" value="{$customer_phone_reservation}" readonly
                               style="border:none; outline: none;"><br>
                        <label>E-mail: </label>
                        <input name="customer_mail_reservation" value="{$customer_mail_reservation}" readonly
                               style="border:none; outline: none;"><br>
                       
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="submit" class="btn btn-primary step step-1" data-step="1"
                                name="button_pressed_reservation">Send Email!
                        </button>
                    </div>
                </div>
                </form>

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...