CREATE TABLE IF NOT EXISTS `clist` (
`sno` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(55) NOT NULL,
`email` varchar(55) NOT NULL,
`password` varchar(55) NOT NULL,
`city` varchar(55) NOT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
autoload.php :
We have to change in autoload.php as follows,
$autoload['libraries'] = array('database','form_validation','uri');
$autoload['helper'] = array('html', 'form', 'url');
register_view.php:
<style type="text/css">
table {
background:#ADDAF1;
border-radius:10px;
margin-top:95px;
}
</style>
<title><?php echo $title;?></title>
<form action="http://justcourse.site40.net/index.php/controllername/methodname/" name="form1" id="form1" method="post" >
<table width="200" border="0" align="center">
<tr>
<td>Name:</td>
<td><input type="text" name="name" id="name"> <font color="#FF0000"><?php echo form_error('name');?></font></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email" id="email"> <font color="#FF0000"><?php echo form_error('email');?></font></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" id="password"> <font color="#FF0000"><?php echo form_error('password');?></font></td>
</tr>
<tr>
<td>City:</td>
<td><select name="city" id="city">
<option value="">Select</option>
<option value="bangalore">bangalore</option>
<option value="vijayawada">vijayawada</option>
</select> <font color="#FF0000"><?php echo form_error('city');?></font></td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="Register"></td></tr>
</table>
</form>
Controller(register.php)
<?php
class register extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model("register_model");
}
public function index()
{
$this->insert();
}
public function insert()
{
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('password', 'Password', 'required|numeric');
$this->form_validation->set_rules('city','City','required');
if ($this->form_validation->run())
{
$register=$this->register_model->insertdata($_POST);
if($register){
echo "<script>alert('added Sucessfully')</script>";
}
}
$data['title']="Registration";
$this->load->view('register_view',$data);
}
}
?>
Model(register_model.php):
<?php
class register_model extends CI_Model {
function insertdata($options = array()){
if(isset($options['name']))
$this->db->set('name',strip_tags($options['name']));
if(isset($options['email']))
$this->db->set('email',strip_tags($options['email']));
if(isset($options['password']))
$this->db->set('password',strip_tags($options['password']));
if(isset($options['city']))
$this->db->set('city',($options['city']));
$this->db->insert("clist");
return $this->db->insert_id();
}
}
?>
02:36
Share:
thanks sir give more example in codeignitor
ReplyDeleteSure rohit..i will update more modules.......
ReplyDeletesir its not working.....i have tried it n ci 3 bt it is not working
ReplyDeleteplease follow instruction as given. It will work.
Deletesir it works bt doesn't go to next page im new to code igniter so i have little problems....im trying and thanks a lot sir @@@@@@im felling happy you can mail me at abhishekkashyap092@gmail.com
ReplyDeletethanks a lot sir ,now i'm going to create a login for this could you help me for this
ReplyDeletePlease Share Your Requirement ,So that we will work For your Requirement kashyap.....
Deletehow to add the pay-pal in codeigniter
ReplyDeletehello sir after using this code
ReplyDelete"An Error Was Encountered
Unable to load the requested class: Uri "
this error will be come, please give me solution .
in auto load page you want change this:
Delete$autoload['libraries'] = array('database','form_validation','uri');
to
$autoload['libraries'] = array('database','form_validation');
Thank You i understand this but i need a simple way but it work i tried it.
ReplyDeletesir its not working after submitting....alert message is not displaying...and data is not stored in DB
ReplyDeleteHi What Error your are Getting,mention here.....
Deletes sir am also having a same problem no errors but not working...
Deletehi dileep kumar change form action as per your file structure......
DeleteThanks sir its very helpful !
ReplyDelete
ReplyDeleteMay i know the Database Name?
i dont know but when i click register it point to some 000webhost.com
ReplyDelete