Welcome Guest, Not a member yet? Register   Sign In
Saving data to MYSQL

I have followed an online guide how to do this. But its not working. I've made some slight changes but nothing is working, help

User inputs info page:

<fieldset class="col-xs-12 col-sm-6 personal-info-wrapper">
                        <input type="hidden" id="user-id">
                        <form method="post">
                            <div class="form-group">
                                <label for="postcode">Enter Postcode Area</label>
                                <input style="font-size:12px" name="postCode" id="postcode" class="form-control required" value="e.g CF11">
                             <div class="form-group">
                                <label for="deliveryCost">Delivery Charge</label>
                                <input style="font-size:12px" name="delivery" id="deliveryCost" class="form-control required" value="e.g 5.00">
                            <button type="button" class="save-settings btn btn-primary btn-xs"
                                title="<?= lang('save') ?>">
                                <span class="glyphicon glyphicon-floppy-disk"></span>
                                <?= lang('save') ?>
                            <input type="submit" name="savePostcode" value="Save Data"/>


    /*load database libray manually
    $this->load->database();       */

    /*load Model
    $this->load->model('Settings_model');   */


    public function savedata()
        /*load registration view form*/

        /*Check submit button */


        echo "Records Saved Successfully";

    /* Insert postcodes to table*/

    function saverecords($postCode,$delivery)

    $query="insert into Postcodes values('','$postCode','$delivery')";

(This post was last modified: 11-19-2019, 05:09 PM by InsiteFX.)

you need to save the record using an associated array.

PHP Code:
// Controller
public function savedata()
    /*load registration view form*/

    /*Check submit button */
$data = [
            'first_name' => $this->input->post('postCode'),
            'last_name'  => $this->input->post('delivery'),

        echo "Records Saved Successfully";

// Model

/* Insert postcodes to table*/
public function saverecords($data)
    return $this-db->insert('Postcodes'$data);

SEECodeIgniter User Guide - Database Reference -> Query Builder Class
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB