Welcome Guest, Not a member yet? Register   Sign In
How Can i Insert data In DataBase
#1

In this Project For inserting Data in database cretaed  basically 3 pages. i m using Wamp Server ..My dataBase Name is "artipick" , table name ="user" and in table 4 Field name  id , username , password , email  .When i will Submit the form Its generate Error..

Plz Reply me..
1)controllers/Register.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Register extends CI_Controller {

public function _construct()
{
parent ::_construct();
$this->load->model(array('mod_user'));
}

/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$email = NULL;
$username = NULL;
$password = NULL;
$submit = NULL;
extract($_POST);
$params['email']=$email;
$params['username']=$username;
$params['password']=$password;
if(isset($submit))
{

$this->mod_user->update($params);
}
$this->load->view('register');
}
}
2)Views/register.php

<ul class="nav navbar-nav navbar-right">
           <li><a href="http://localhost/Artipick/index.php/register">Register</a></li>
           <li class="active"><a href="http://localhost/Artipick/index.php/register">Login <span class="sr-only">(current)</span></a></li></ul>

<form action="register" method="POST">
<input type="text" name="email" placeholder="Email Id" /><br/>
<input type="text" name="username" placeholder="User Name" /><br/>
<input type="text" name="password" placeholder="Password" /><br/>
<button type="submit" name="submit" value="save">Save</button>
</form>
3)Models/Mod_user.php


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Mod_user extends CI_Model {
protected $table= 'user';
function _construct()
{
parent ::_construtct();
}
public function update($params)
{
$fields = array(
'email' => $params['email'],
'username' => $params['username'],
'password' => $params['password']
);
$this->db->insert($this->table , $fields);
}

}

Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
How Can i Insert data In DataBase - by viveksoftcomp - 10-16-2015, 06:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB