=========================================================
signup.php registration
=============================================================
<html>
<head>
<title>
Registration
</title>
</head>
<body>
<?php echo $this->load->helper('form'); ?>
<?php echo form_open('newreg/inserdata'); ?>
<table border="1">
<tr>
<td colspan="3" align="center"><b>Registration</b></td>
</tr>
<tr>
<th>First Name</th>
<td><input type="text" name="fname"> </td>
</tr>
<tr>
<th>Second Name</th>
<td><input type="text" name="sname"></td>
</tr>
<tr>
<th>Last Name</th>
<td><input type="text" name="lname"> </td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" name="pass" ></td>
</tr>
<tr>
<th>Qulification</th>
<td>
<select name="qul">
<option>select</option>
<option value="bca">BCA</option>
<option value="mca">Mca</option>
<option value="phd">Phd</option>
</select>
</td>
</tr>
<tr>
<td colspan="3"><input type="submit" value="ADD"></td>
</tr>
</table>
<?php echo form_close(); ?>
</body>
</html>
==========================================================
login.php
==========================================================
<html>
<head>
<title>
Login
</title>
</head>
<body>
<?php $this->load->helper('form'); ?>
<?php echo form_open('newreg/login1'); ?>
<table border="1">
<tr>
<th>User Name</th>
<td><input type="text" name="fname"></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Login"></td>
</tr>
</table>
<?php echo form_close(); ?>
</body>
</html>
==============================================
uprofile.php Show data
==============================================
<html>
<head>
</head>
<body>
<td> <a href="logout">Logout</a></td>
<table border="1">
<tr>
<th>First Name</th>
<td><?php echo $fname; ?></td>
</tr>
<tr>
<th>Second Name</th>
<td><?php echo $sname; ?></td>
</tr>
<tr>
<th>Last Name</th>
<td><?php echo $lname; ?></td>
</tr>
<tr>
<th>Password</th>
<th><?php echo $pass; ?></th>
</tr>
<tr>
<th>Qulification</th>
<td><?php echo $qul; ?></td>
</tr>
<tr>
<td><a href="<?php echo base_url(). "index.php/newreg/edit/". $newreg_id; ?>">Edit</a></td>
</tr>
</table>
</body>
</html>
==============================================================
myedit.php edit data
=============================================================
<html>
<head>
</head>
<body>
<table border="1">
<tr>
<th>First Name</th>
<td><input type="text" name="fname" value="<?php echo $userdata['fname']; ?>" </td>
</tr>
<tr>
<th>Second Name</th>
<td><input type="text" name="sname" value="<?php echo $userdata['sname']; ?>" </td>
</tr>
<tr>
<th>Last Name</th>
<td><input type="text" name="lname" value="<?php echo $userdata['lname']; ?>" </td>
</tr>
<tr>
<th>Password</th>
<td><input type="text" name="pass" value="<?php echo $userdata['pass']; ?>"></td>
</tr>
<tr>
<th>Qulification</th>
<td><input type="text" name="qul" value="<?php echo $userdata['qul']; ?>"></td>
</tr>
<tr>
<td>
<input type="submit" value="Upadate">
</td>
</tr>
</table>
</body>
</html>
==================================================================
newreg.php this is conroller file
==================================================================
function signup(){ Template::set_view('newreg/signup');}
function inserdata(){
$this->load->helper(array('form','url')); $this->load->library('form_validation'); $this->form_validation->set_rules('fname','First Name','required|min_length[1]|max_length[50]'); $this->form_validation->set_rules('sname','Second Name','required|min_length[1]|max_length[50]'); $this->form_validation->set_rules('lname','Last Name','required|min_length[1]|max_length[50]'); $this->form_validation->set_rules('pass','Password','required|min_length[1]|max_length[50]'); $this->form_validation->set_rules('qul','Qulification','required|min_length[1]|max_length[10]'); if($this->form_validation->run()==FALSE) { Template::set_message('Wrong input'); Template::render(); } else { $data=$_POST;
$this->load->model('newreg_model','reg'); $getid=$this->reg->insert($data); $this->session->set_userdata('newreg_id',$getid);
}}function login(){ Template::set_view('newreg/login'); Template::render();}
function login1(){ $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); $this->form_validation->set_rules('fname', 'First Name', 'required|min_length[1]|max_length[50]'); $this->form_validation->set_rules('pass', 'Password', 'required|min_length[1]|max_length[50]'); if ($this->form_validation->run() == False) { Template::set_view('newreg/login');
} else { $data = $_POST;
$this->load->model('newreg_model', 'reg'); $getid = $this->reg->login11($data); if ($getid == TRUE) { $sess = $_POST;
$this->session->set_userdata($sess); $getid = $this->reg->login11($sess);
if ($getid != FALSE) { $data = $getid;
$this->load->view('uprofile', $data); }
} else { Template::set_message('invalid user','error'); Template::set_view('newreg/login'); Template::render();
}
}
}
//logout
function edit($data){ $this->session->userdata('newreg_id'); $this->load->model('newreg_model','reg'); $userdata = $this->reg->show($data); echo '<pre>'; print_r($userdata); die;
Template::set_view('newreg/myedit');
Template::set('userdata',$userdata); Template::render();
}
function logout(){
$this->session->unset_userdata('newreg_id');
//session_destroy(); $this->session->sess_destroy(); redirect('newreg/login');}
===========================================================
newreg_model.php this is model
=========================================================
function insert($data){
$this->db->insert('bf_newreg',$data);}function login11($data){ $this->db->select('*'); $this->db->where('fname',$data['fname']);
$this->db->where('pass',$data['pass']); $abc=$this->db->get('bf_newreg'); return $abc->row_array();
}
function show($data){
$this->db->select('*');
$this->db->where('newreg_id',$data); $ans=$this->db->get('bf_newreg');
return $ans->row_array();}
No comments:
Post a Comment