0

I am using twilio for sending sms.i can sent sms but i can't receive incoming sms and can't store in my database.When i receive SMS from my customers to my twilio number. i want to get the fields like from number and the body and save to my databse. In the below i gave codes.please tell whats the problem and what need to change to store data in my database.

View Code:

<!--sidebar end-->
<!--main content start-->
<section id="main-content">
    <section class="wrapper site-min-height">
        <!-- page start-->
        <section class="panel panel--colour-orange">
            <header class="panel-heading">
            </header>

            <form role="form" action="patient/receivesmsadd" method="post" style="border: 0px solid #ccc; padding: 0px;">

            <div class="col-md-12" style="padding: 30px 20px 15px 15px;">

            <div class="col-md-6">
                <div class="panel-body-wrapper">
                        <li class="list-group-item" style="border-top: 2px solid #2789D9;">

                            <div class="form-group" style="margin-bottom: 10px">
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input type="text" placeholder="Appointment id" name="appointment_id" id="appointment_id" class="numeric form-control" maxlength="13" value="<?php echo($_REQUEST['body[0]']); ?>">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input type="text" placeholder="Bill Process" name="acceptance" id="acceptance" class="numeric form-control" value="<?php echo($_REQUEST['body[1]']); ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input type="text" name="payment_method" placeholder="Payment Method" id="payment_method" class="numeric form-control" value="<?php echo($_REQUEST['body[2]']); ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input type="text" name="phone" placeholder="Phone" id="phone" class="numeric form-control" value="<?php echo($_REQUEST['from']); ?>">
                                    </div>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>

            </div>

        </div>
        <section class="" style="margin-left: 25px;">
            <button type="submit" name="submit" class="btn btn-blue" style="margin-left: 5px;margin-bottom: 30px;">Create</button>
        </section>
        </form>

        </section>
    </section>
</section>

Controller Code:

function receivesmsadd(){
        $data = array();
        $data['appointment_id']        = $this->input->post('appointment_id');
        $data['acceptance']            = $this->input->post('acceptance');
        $data['payment_method']        = $this->input->post('payment_method');
        $data['phone']                 = $this->input->post('phone');

        $this->load->model('patient_model');
        if ($this->patient_model->receivesms($data)) {
            $this->session->set_flashdata('message','Added Successfully');
        } else {
            $this->session->set_flashdata('message','Failed to Added');
        }     
    }

Mode code:

 function receivesms($data) {
        return $this->db->insert('receivesms',$data);
    }

0 Answers0