Note that there are some explanatory texts on larger screens.

plurals
  1. POcodeigniter INSERT only inserting variable names
    primarykey
    data
    text
    <p>i've lost a good few hours on this and i'm sure it's something quite simple!</p> <p>I'm quite new to codeigniter.</p> <p>Basically i want to perform a simple INSERT into my database using values recieved from my form here is my view:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;head&gt; &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8"&gt; &lt;title&gt;Page Title&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="formage"&gt; &lt;?php echo validation_errors(); ?&gt; &lt;?php echo form_open('../add_client'); ?&gt; &lt;p&gt; &lt;?php echo form_label('First Name', 'first_name');?&gt; &lt;?php echo form_input('first_name', '', 'id="first_name"' );?&gt; &lt;/p&gt; &lt;p&gt; &lt;?php echo form_label('Last Name', 'second_name');?&gt; &lt;?php echo form_input('second_name', '', 'id="second_name"' );?&gt; &lt;/p&gt; &lt;p&gt; &lt;?php echo form_label('Email Address', 'email_address');?&gt; &lt;?php echo form_input('email_address', '', 'id="email_address"' );?&gt; &lt;/p&gt; &lt;p&gt; &lt;?php echo form_label('Password', 'password');?&gt; &lt;?php echo form_password('password', '', 'id="password"' );?&gt; &lt;/p&gt; &lt;p&gt; &lt;?php echo form_label('Confirm Password', 'passwordconf');?&gt; &lt;?php echo form_password('passwordconf', '', 'id="passwordconf"' );?&gt; &lt;/p&gt; &lt;p&gt; &lt;?php echo form_submit('submit', 'Add New Client');?&gt; &lt;/p&gt; &lt;?php echo form_close(); ?&gt; &lt;/div&gt; </code></pre> <p> </p> <p>This calls my controller:</p> <pre><code>&lt;?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class Add_client extends CI_Controller{ function __construct(){ parent::__construct(); } function index(){ $this-&gt;load-&gt;library('form_validation'); $this-&gt;form_validation-&gt;set_rules('first_name', 'First Name', 'required'); $this-&gt;form_validation-&gt;set_rules('second_name', 'Second Name', 'required'); $this-&gt;form_validation-&gt;set_rules('email_address', 'Email Address', 'required|valid_email'); $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'required|min_length(4)'); $this-&gt;form_validation-&gt;set_rules('passwordconf', 'Password', 'required|matches[password]'); if($this-&gt;form_validation-&gt;run() !== false){ $this-&gt;load-&gt;model('add_client_model'); $this-&gt;add_client_model-&gt;addUser( $this-&gt;input-&gt;post('first_name'), $this-&gt;input-&gt;post('second_name'), $this-&gt;input-&gt;post('email_address'), $this-&gt;input-&gt;post('password')); } $this-&gt;load-&gt;view('add_client_view'); } } </code></pre> <p>Which in turn calls the addUser function from my model:</p> <pre><code>&lt;?php class Add_client_model extends CI_Model{ function __construct(){ } public function addUser($fname, $sname, $email, $password){ $this-&gt;db-&gt;set('first_name', $fname); $this-&gt;db-&gt;set('second_name', $sname); $this-&gt;db-&gt;set('email_address', $email); $this-&gt;db-&gt;set('pasword', sha1($name)); $this-&gt;db-&gt;insert('users'); } } </code></pre> <p>The problem i am having is that whenever i submit my form and the function is called it seems to insert the variable name like so (see second row):</p> <p><a href="https://dl.dropbox.com/u/76853467/Picture%204.png" rel="nofollow">https://dl.dropbox.com/u/76853467/Picture%204.png</a></p> <p>I cant seem to get it to accept the post data i plug into my function parameters!</p> <p>Any suggestions? Much thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload