CodeIgniter Laravel PHP Example Javascript jQuery MORE Videos New

User Signup example CodeIgniter framework


In this example we will discuss about User Signup example CodeIgniter framework.

We use two file for User Signup example CodeIgniter framework.

  1. User.php (CodeIgniter\application\controllers\User.php )
  2. student_registration.php (CodeIgniter\application\views\student_registration.php)

User.php

<?php
class User extends CI_Controller 
{
	public function __construct()
	{
	parent::__construct();
	$this->load->database();
	$this->load->helper('url');
	}
 
	public function sign_up()
	{
		if($this->input->post('save'))
		{
		$name=$this->input->post('name');
		$email=$this->input->post('email');
		$password=$this->input->post('pass');
		$phone=$this->input->post('phone');
		$que=$this->db->query("select * from user_login where email='$email'");
		$row = $que->num_rows();
		if(count($row)>0)
		{
		$data['error']="<h3 style='color:red'>Email id already exists</h3>";
		}
		else
		{
		$que=$this->db->query("insert into user_login values('','$name','$email','$phone','$password')");
		
		$data['error']="<h3 style='color:blue'>Your account created successfully</h3>";
		}			
				
		}
	    $this->load->view('student_registration',@$data);	
	}
	
	
}
?>

student_registration.php

<!DOCTYPE html>
<html>
<head>
<title>Student Signup form</title>
</head>
 
<body>
<form method="post">
<table width="600" align="center" border="1" cellspacing="5" cellpadding="5">
	<tr>
		<td colspan="2"><?php echo @$error; ?></td>
	</tr>	
  <tr>
    <td width="230">Enter Your Name </td>
    <td width="329"><input type="text" name="name"/></td>
  </tr>
  
  <tr>
    <td>Enter Your Email </td>
    <td><input type="text" name="email"/></td>
  </tr>
  <tr>
    <td>Enter Your Mobile </td>
    <td><input type="text" name="phone"/></td>
  </tr>
  <tr>
    <td>Enter Your Password </td>
    <td><input type="password" name="pass"/></td>
  </tr>
 <tr>
    <td colspan="2" align="center">
	<input type="submit" name="save" value="Register Me"/></td>
  </tr>
</table>
	</form>
</body>
</html>

Now run the program on your browser with the below URL:

http://localhost/CodeIgniter/index.php/User/student_registration