Codeigniter Login and Registration Tutorial & Source Code

On 7/21/2017 31 Comments so far

Today we'll see a codeigniter tutorial demonstrating user login and registration system. As you know Login and Signup Module (User Management System) forms the base for membership driven websites and applications. I have written about codeingiter login and registration process separately earlier, but got requests from blog readers to provide a complete user management module. So in today's post, I have tried to cover as much as possible in user module comprising home, login, signup and user profile/dashboard page.

So let us see how to create complete codeigniter login and registration system.

Create Database for CI Login & Signup Module:

First create the mysql database required for the codeigniter user management system.

Read Also:
CREATE DATABASE `testdb`;
USE `testdb`;

CREATE TABLE IF NOT EXISTS `user` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
  `fname` varchar(30) NOT NULL,
  `lname` varchar(30) NOT NULL,
  `email` varchar(60) NOT NULL,
  `password` varchar(40) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Run the above the sql commands in mysql db and create the necessary database and table.

Build CodeIgniter Login and Registration System:

To build our codeigniter login and registration system we need a bunch of controller, view and model files. Here are the files we are going to create.

  • home.php - This is the Home page controller of the user management application.
  • login.php - It's the user login form controller file.
  • signup.php - This one is the user signup page(registration) controller.
  • profile.php - This is the controller for my profile/dashboard page.
  • home_view.php - It is the Home page view file.
  • login_view.php - View file for login controller.
  • signup_view.php - View file for signup/registration controller.
  • profile_view.php – It is the user profile view file.
  • user_model.php - This is the model file for the user management module. Here we place all the db transactions of the module.

Codeignitor User Login and Registration System:

In case you don't know, below are the steps breakdown for what we are going to build in this user login/signup system in code igniter.

  1. The user enters the Home page which contains links for Login and Signup on top navigation menu.
  2. As for New Users » user click on Signup link » user redirected to signup/registration form » user fills up the form details and submit » process user details and store it into database » notify user.
  3. As for Registered Users » user click on the Login link on Home page » user redirected to login form » user enter login credentials » authenticate user and redirect to User Profile page.
  4. For Singed-in users » Show User's name and Logout link on top menu bar.
  5. When user clicks on Logout » destroy session and redirect to Home page.

Note: As for designing user interface, I have used the readily available Twitter Bootstrap CSS as it's easier this way and mobile responsive in nature. Check here to know about using bootstrap with codeigniter framework.

Home.php

This is controller for the Home/Main page of the user management module and it shows Login and Signup link at the top menu for guests and User's Name and Logout link for signed-in users.

<?php
class home extends CI_Controller
{
 public function __construct()
 {
  parent::__construct();
  $this->load->helper(array('url', 'html'));
  $this->load->library('session');
 }
 
 function index()
 {
  $this->load->view('home_view');
 }
 
 function logout()
 {
  // destroy session
        $data = array('login' => '', 'uname' => '', 'uid' => '');
        $this->session->unset_userdata($data);
        $this->session->sess_destroy();
  redirect('home/index');
 }
}
?>

Signup.php

This is the controller file for the codeigniter user registration form. It collects first name, last name, email id and password from the user and validates the input and stores it into database.

<?php
class signup extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->helper(array('form','url'));
        $this->load->library(array('session', 'form_validation'));
        $this->load->database();
        $this->load->model('user_model');
    }

    function index()
    {
        // set form validation rules
        $this->form_validation->set_rules('fname', 'First Name', 'trim|required|alpha|min_length[3]|max_length[30]|xss_clean');
        $this->form_validation->set_rules('lname', 'Last Name', 'trim|required|alpha|min_length[3]|max_length[30]|xss_clean');
        $this->form_validation->set_rules('email', 'Email ID', 'trim|required|valid_email|is_unique[user.email]');
        $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[cpassword]|md5');
        $this->form_validation->set_rules('cpassword', 'Confirm Password', 'trim|required');

        // submit
        if ($this->form_validation->run() == FALSE)
        {
            // fails
            $this->load->view('signup_view');
        }
        else
        {
            //insert user details into db
            $data = array(
                'fname' => $this->input->post('fname'),
                'lname' => $this->input->post('lname'),
                'email' => $this->input->post('email'),
                'password' => $this->input->post('password')
            );

            if ($this->user_model->insert_user($data))
            {
                $this->session->set_flashdata('msg','<div class="alert alert-success text-center">You are Successfully Registered! Please login to access your Profile!</div>');
                redirect('signup/index');
            }
            else
            {
                // error
                $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Oops! Error.  Please try again later!!!</div>');
                redirect('signup/index');
            }
        }
    }
}
?>

This is how the signup form looks like,

codeigniter-signup-form

All fields are mandatory and once the user submits the form the input will be validated against a set of form validation rules. If the validation fails, user will be prompted to enter right data by showing the error message like this.

codeigniter-signup-form-validation-error

If validation succeeds, registration process will be completed and notified to the user.

Login.php

This is the controller file for user login process. It asks for user's email address and password and check if the provided login credentials are correct or not.

<?php
class login extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->helper(array('form','url','html'));
        $this->load->library(array('session', 'form_validation'));
        $this->load->database();
        $this->load->model('user_model');
    }
    
    function index()
    {
        // get form input
        $email = $this->input->post("email");
        $password = $this->input->post("password");

        // form validation
        $this->form_validation->set_rules("email", "Email-ID", "trim|required|xss_clean");
        $this->form_validation->set_rules("password", "Password", "trim|required|xss_clean");

        if ($this->form_validation->run() == FALSE)
        {
            // validation fail
            $this->load->view('login_view');
        }
        else
        {
            // check for user credentials
            $uresult = $this->user_model->get_user($email, $password);
            if (count($uresult) > 0)
            {
                // set session
                $sess_data = array('login' => TRUE, 'uname' => $uresult[0]->fname, 'uid' => $uresult[0]->id);
                $this->session->set_userdata($sess_data);
                redirect("profile/index");
            }
            else
            {
                $this->session->set_flashdata('msg', '<div class="alert alert-danger text-center">Wrong Email-ID or Password!</div>');
                redirect('login/index');
            }
        }
    }
}
?>

It produces a login form like this,

codeigniter-login-system-form

If login failed, the user will be shown an error message like this,

codeigniter-login-form-validation-error

If user credentials are valid, then it will be stored in session and user will be redirected to profile/dashboard page.

Profile.php

This is the controller for the User Profile page. It lists user profile summary and other details.

<?php
class profile extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->helper(array('url','html'));
        $this->load->library('session');
        $this->load->database();
        $this->load->model('user_model');
    }

    function index()
    {
        $details = $this->user_model->get_user_by_id($this->session->userdata('uid'));
        $data['uname'] = $details[0]->fname . " " . $details[0]->lname;
        $data['uemail'] = $details[0]->email;
        $this->load->view('profile_view', $data);
    }
}
?>

That's it. These are all the important controller files required for the code igniter user registration and login system. Now run the app and go to Home page.

codeigniter-login-and-registration-tutorial-home-page
CodeIgniter Login and Registration System - Home Page

Click on Signup link and it will take you to the user signup form.

codeigniter-login-and-registration-tutorial-signup-page

Now enter the details and submit the form. If things gone right, you will be shown with a success message like this,

codeignitor-user-registration-process-success

Now click on the Login link to go to the login page.

codeigniter-login-and-registration-tutorial-login-page

Provide the email and password which you have registered earlier. Now you will be redirected to your Profile page.
codeigniter-login-and-registration-tutorial-profile-page
CodeIgniter Login and Registration Module - User Profile Page

To sign-out the session, click on Logout link at the top navigation menu which will take you back to Home page.

CodeIgniter Login and Registration Source Code:

Download Source

Read Also:

Well! Now we have created user login and registration system in codeignator. I hope you have enjoyed this codeigniter login and registration tutorial. Please let me know your queries through comments :)

PHP Login and Registration Script with MySQL Example

On 2/21/2017 43 Comments so far

PHP Login and Registration Script: User Login/registration system is one of the key components of any membership driven websites and the ability to build them is a must have skill for any web developer. In this post, let us see how to create a complete login and registration system using php and mysql database.

This tutorial is fairly simple and easy to understand, but it covers as much as required to build advanced login/registration system - right from data validation to maintaining php sessions for authenticated access.

MySQL Database for Login/Registration Module

Before entering into the coding part, first let us build the database required for this example.

Read Also:
CREATE DATABASE `testdb`;
USE `testdb`;

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(8) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL,
  `email` varchar(60) NOT NULL,
  `password` varchar(40) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Run this sql file in phpmyadmin interface and create the database and table.

PHP Script for Login and Registration System

To build the login/registration system we need to create the following files.

  • index.php - This is the home page of our application
  • register.php - It contains the user sign up form
  • login.php - It contains the login form
  • logout.php - This contains the user logout script
  • dbconnect.php - MySQL database connection script

System Flow for User Login Registration Module

These are the steps breakdown of the user registration/login module we are going to build.

  1. The Home page (index.php) contains links for login and sign up process in top navigation menu.
  2. For new users » click on sigup link » user redirected to registration form » fill up the form and submit » validate the form input » registration succeed » notify user and redirect to login page.
  3. For registered users » click on login link on index.php » user redirected to login page » user provide login credentials » authenticate user and redirect to index page.
  4. For signed in users » show user's name and logout link on navigation bar.
  5. User clicks on logout » delete user details from session variable and destroy session » redirect to Home page.

Note: This tutorial uses twitter bootstrap framework for css. I prefer to use this as it's readily available and you can easily integrate bootstrap with HTML. But if you prefer custom style sheet then you can simply attach one and replace all the class selectors used in the html tags with your own. However the program functionality remains the same and will not be disturbed.

Dbconnect.php

This is where we connect to the mysql database. Keeping database connectivity in a separate file is very handy. This way you can get access to database across multiple files by simply including the file once and access it anywhere.

<?php
//connect to mysql database
$con = mysqli_connect("localhost", "myusername", "mypassword", "testdb") or die("Error " . mysqli_error($con));
?>

Register.php

This php file contains the code for the user registration process. The access to this page will be restricted for signed in user. We do this by checking out the session variable.

<?php
session_start();

if(isset($_SESSION['usr_id'])) {
    header("Location: index.php");
}

include_once 'dbconnect.php';

//set validation error flag as false
$error = false;

//check if form is submitted
if (isset($_POST['signup'])) {
    $name = mysqli_real_escape_string($con, $_POST['name']);
    $email = mysqli_real_escape_string($con, $_POST['email']);
    $password = mysqli_real_escape_string($con, $_POST['password']);
    $cpassword = mysqli_real_escape_string($con, $_POST['cpassword']);
    
    //name can contain only alpha characters and space
    if (!preg_match("/^[a-zA-Z ]+$/",$name)) {
        $error = true;
        $name_error = "Name must contain only alphabets and space";
    }
    if(!filter_var($email,FILTER_VALIDATE_EMAIL)) {
        $error = true;
        $email_error = "Please Enter Valid Email ID";
    }
    if(strlen($password) < 6) {
        $error = true;
        $password_error = "Password must be minimum of 6 characters";
    }
    if($password != $cpassword) {
        $error = true;
        $cpassword_error = "Password and Confirm Password doesn't match";
    }
    if (!$error) {
        if(mysqli_query($con, "INSERT INTO users(name,email,password) VALUES('" . $name . "', '" . $email . "', '" . md5($password) . "')")) {
            $successmsg = "Successfully Registered! <a href='login.php'>Click here to Login</a>";
        } else {
            $errormsg = "Error in registering...Please try again later!";
        }
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>User Registration Script</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" >
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
</head>
<body>

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <!-- add header -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.php">Koding Made Simple</a>
        </div>
        <!-- menu items -->
        <div class="collapse navbar-collapse" id="navbar1">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="login.php">Login</a></li>
                <li class="active"><a href="register.php">Sign Up</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container">
    <div class="row">
        <div class="col-md-4 col-md-offset-4 well">
            <form role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="signupform">
                <fieldset>
                    <legend>Sign Up</legend>

                    <div class="form-group">
                        <label for="name">Name</label>
                        <input type="text" name="name" placeholder="Enter Full Name" required value="<?php if($error) echo $name; ?>" class="form-control" />
                        <span class="text-danger"><?php if (isset($name_error)) echo $name_error; ?></span>
                    </div>
                    
                    <div class="form-group">
                        <label for="name">Email</label>
                        <input type="text" name="email" placeholder="Email" required value="<?php if($error) echo $email; ?>" class="form-control" />
                        <span class="text-danger"><?php if (isset($email_error)) echo $email_error; ?></span>
                    </div>

                    <div class="form-group">
                        <label for="name">Password</label>
                        <input type="password" name="password" placeholder="Password" required class="form-control" />
                        <span class="text-danger"><?php if (isset($password_error)) echo $password_error; ?></span>
                    </div>

                    <div class="form-group">
                        <label for="name">Confirm Password</label>
                        <input type="password" name="cpassword" placeholder="Confirm Password" required class="form-control" />
                        <span class="text-danger"><?php if (isset($cpassword_error)) echo $cpassword_error; ?></span>
                    </div>

                    <div class="form-group">
                        <input type="submit" name="signup" value="Sign Up" class="btn btn-primary" />
                    </div>
                </fieldset>
            </form>
            <span class="text-success"><?php if (isset($successmsg)) { echo $successmsg; } ?></span>
            <span class="text-danger"><?php if (isset($errormsg)) { echo $errormsg; } ?></span>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4 col-md-offset-4 text-center">    
        Already Registered? <a href="login.php">Login Here</a>
        </div>
    </div>
</div>
<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

This is how the registration form looks like.

php-sign-up-script

Registration form requires user to fill up name, email id and password and confirm password fields. All the fields are mandatory and user will be asked to provide the data if it is left blank like this.

php-registration-form-validation

Once the user fills out the details and submits the form for sign up, we sanitize the received data to avoid sql injection and validate the form input. If validation fails the user will be shown with the appropriate error message below each form input like this.

php-registration-form-validation-error
php-registration-password-validation

If the validation succeeds the data will be stored in the database and user will be shown with the login link.

Login.php

This file contains the php code for user login process. The access to login form will be restricted for signed in users by checking if the php session is set or not.

<?php
session_start();

if(isset($_SESSION['usr_id'])!="") {
    header("Location: index.php");
}

include_once 'dbconnect.php';

//check if form is submitted
if (isset($_POST['login'])) {

    $email = mysqli_real_escape_string($con, $_POST['email']);
    $password = mysqli_real_escape_string($con, $_POST['password']);
    $result = mysqli_query($con, "SELECT * FROM users WHERE email = '" . $email. "' and password = '" . md5($password) . "'");

    if ($row = mysqli_fetch_array($result)) {
        $_SESSION['usr_id'] = $row['id'];
        $_SESSION['usr_name'] = $row['name'];
        header("Location: index.php");
    } else {
        $errormsg = "Incorrect Email or Password!!!";
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>PHP Login Script</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" >
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
</head>
<body>

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <!-- add header -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.php">Koding Made Simple</a>
        </div>
        <!-- menu items -->
        <div class="collapse navbar-collapse" id="navbar1">
            <ul class="nav navbar-nav navbar-right">
                <li class="active"><a href="login.php">Login</a></li>
                <li><a href="register.php">Sign Up</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container">
    <div class="row">
        <div class="col-md-4 col-md-offset-4 well">
            <form role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform">
                <fieldset>
                    <legend>Login</legend>
                    
                    <div class="form-group">
                        <label for="name">Email</label>
                        <input type="text" name="email" placeholder="Your Email" required class="form-control" />
                    </div>

                    <div class="form-group">
                        <label for="name">Password</label>
                        <input type="password" name="password" placeholder="Your Password" required class="form-control" />
                    </div>

                    <div class="form-group">
                        <input type="submit" name="login" value="Login" class="btn btn-primary" />
                    </div>
                </fieldset>
            </form>
            <span class="text-danger"><?php if (isset($errormsg)) { echo $errormsg; } ?></span>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4 col-md-offset-4 text-center">    
        New User? <a href="register.php">Sign Up Here</a>
        </div>
    </div>
</div>

<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

This file produces a login form similar to this.

php-login-system-script

Login form requires users to provide login credentials (email & password). Both the input fields are mandatory and notify user to fill out if left blank.

php-login-system-form-validation

Here too we sanitize the data and check for user authentication against database records. If it fails, we notify the user with error message like this,

php-login-system-form-validation-error

If the user credentials are legitimate then we create session and store user's id and name in the session variable and redirect to index.php.

Index.php

This is the home page of our application and shows login and sign up menu links for visitors and for signed in members will show their name and logout link respectively.

<?php
session_start();
include_once 'dbconnect.php';
?>
<!DOCTYPE html>
<html>
<head>
    <title>Home | Koding Made Simple</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" >
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
</head>
<body>

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.php">Koding Made Simple</a>
        </div>
        <div class="collapse navbar-collapse" id="navbar1">
            <ul class="nav navbar-nav navbar-right">
                <?php if (isset($_SESSION['usr_id'])) { ?>
                <li><p class="navbar-text">Signed in as <?php echo $_SESSION['usr_name']; ?></p></li>
                <li><a href="logout.php">Log Out</a></li>
                <?php } else { ?>
                <li><a href="login.php">Login</a></li>
                <li><a href="register.php">Sign Up</a></li>
                <?php } ?>
            </ul>
        </div>
    </div>
</nav>

<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

Logout.php

This file will be fired up when the user clicks on the logout link. The user logout process is fairly simple. It destroy the session and unset the user data from the session.

<?php
session_start();

if(isset($_SESSION['usr_id'])) {
    session_destroy();
    unset($_SESSION['usr_id']);
    unset($_SESSION['usr_name']);
    header("Location: index.php");
} else {
    header("Location: index.php");
}
?>

Once you created all the above files, run the app and you will see the home page like this,

php-login-registration-system-home
index.php - Home Page

Now click on the sign up link and you will be redirected to the user registration form,

php-registration-form

Now enter the form details and submit the sign up button. If everything goes right then you will be registered and notified with a message like this,

php-registration-success

Now go to the login form through the login link.

Provide the login credentials and you will be signed in and redirected to the index page.

signed-in-user-home-page
index.php as signed-in user

Click on logout to sign out the session and you will be taken back to the index page again.

home page
After Log out

Download

That's it. You have successfully created user login and registration system in php and mysql.

Read Also:

I hope you find this php login/registration script useful. Meet you in another interesting tutorial!

How to Insert JSON Data into MySQL using PHP

On 2/21/2017 55 Comments so far

Hi, in this PHP TUTORIAL, we'll see How to insert JSON Data into MySQL using PHP. Check out its reverse process of Converting Data from MySQL to JSON Format in PHP here. Converting json to mysql using php includes several steps and you will learn things like how to read json file, convert json to array and insert that json array into mysql database in this tutorial. For those who wonder what is JSON, let me give a brief introduction.

What is JSON File Format?

JSON file contains information stored in JSON format and has the extension of "*.json". JSON stands for JavaScript Object Notation and is a light weight data exchange format. Being less cluttered and more readable than XML, it has become an easy alternative format to store and exchange data. All modern browsers supports JSON format.

Example of a JSON File

Read Also:

Do you want to know how a JSON file looks like? Well here is the sample.

json-file-example

As you can see by yourself, the JSON format is very human readable and the above file contains some employee details. I'm going to use this file as an example for this tutorial and show you how to insert this JSON object into MySQL database in PHP step by step.

Step 1: Connect PHP to MySQL Database

As the first and foremost step we have to connect PHP to the MySQL database in order to insert JSON data into MySQL DB. For that we use mysql_connect() function to connect PHP with MySQL.

<?php
    $con = mysql_connect("username","password","") or die('Could not connect: ' . mysql_error());
    mysql_select_db("employee", $con);
?>

Here "employee" is the MySQL Database name we want to store the JSON object. Learn more about using mysqli library for php and mysql database connection here.

Step 2: Read the JSON file in PHP

Next we have to read the JSON file and store its contents to a PHP variable. But how to read json file in php? Well! PHP supports the function file_get_contents() which will read an entire file and returns it as a string. Let’s use it to read our JSON file.

<?php
    //read the json file contents
    $jsondata = file_get_contents('empdetails.json');
?>

Here "empdetails.json" is the JSON file name we want to read.

Step 3: Convert JSON String into PHP Array

The next step for us is to convert json to array. Which is likely we have to convert the JSON string we got from the above step to PHP associative array. Again we use the PHP json decode function which decodes JSON string into PHP array.

<?php
    //convert json object to php associative array
    $data = json_decode($jsondata, true);
?>

The first parameter $jsondata contains the JSON file contents.

The second parameter true will convert the string into php associative array.

Step 4: Extract the Array Values

Next we have to parse the above JSON array element one by one and store them into PHP variables.

<?php
    //get the employee details
    $id = $data['empid'];
    $name = $data['personal']['name'];
    $gender = $data['personal']['gender'];
    $age = $data['personal']['age'];
    $streetaddress = $data['personal']['address']['streetaddress'];
    $city = $data['personal']['address']['city'];
    $state = $data['personal']['address']['state'];
    $postalcode = $data['personal']['address']['postalcode'];
    $designation = $data['profile']['designation'];
    $department = $data['profile']['department'];
?>

Step 5: Insert JSON to MySQL Database with PHP Code

Using the above steps, we have extracted all the values from the JSON file. Finally let's insert the extracted JSON object values into the MySQL table.

<?php
    //insert into mysql table
    $sql = "INSERT INTO tbl_emp(empid, empname, gender, age, streetaddress, city, state, postalcode, designation, department)
    VALUES('$id', '$name', '$gender', '$age', '$streetaddress', '$city', '$state', '$postalcode', '$designation', '$department')";
    if(!mysql_query($sql,$con))
    {
        die('Error : ' . mysql_error());
    }
?>

We are done!!! Now we have successfully imported JSON data into MySQL database.

Here is the complete php code snippet I have used to insert JSON to MySQL using PHP.

Complete PHP Script

<?php
    //connect to mysql db
    $con = mysql_connect("username","password","") or die('Could not connect: ' . mysql_error());
    //connect to the employee database
    mysql_select_db("employee", $con);

    //read the json file contents
    $jsondata = file_get_contents('empdetails.json');
    
    //convert json object to php associative array
    $data = json_decode($jsondata, true);
    
    //get the employee details
    $id = $data['empid'];
    $name = $data['personal']['name'];
    $gender = $data['personal']['gender'];
    $age = $data['personal']['age'];
    $streetaddress = $data['personal']['address']['streetaddress'];
    $city = $data['personal']['address']['city'];
    $state = $data['personal']['address']['state'];
    $postalcode = $data['personal']['address']['postalcode'];
    $designation = $data['profile']['designation'];
    $department = $data['profile']['department'];
    
    //insert into mysql table
    $sql = "INSERT INTO tbl_emp(empid, empname, gender, age, streetaddress, city, state, postalcode, designation, department)
    VALUES('$id', '$name', '$gender', '$age', '$streetaddress', '$city', '$state', '$postalcode', '$designation', '$department')";
    if(!mysql_query($sql,$con))
    {
        die('Error : ' . mysql_error());
    }
?>

empdetails.json

{
    "empid": "SJ011MS",
    "personal": {
        "name": "Smith Jones",
        "gender": "Male",
        "age": "28",
        "address": {
            "streetaddress": "7 24th Street",
            "city": "New York",
            "state": "NY",
            "postalcode": "10038"
        }
    },
    "profile": {
        "designation": "Deputy General",
        "department": "Finance"
    }
}

Read:

Hope this tutorial helps you to understand how to insert JSON data into MySQL using PHP.

Last Modified: Feb-21-2017

How to Convert Data from MySQL to JSON using PHP

On 2/21/2017 105 Comments so far

In PHP, Converting Data from MySQL to JSON Format is one of the prominent tasks in Web Development. JSON has gained popularity over the years and is preferred over xml as data exchange format between web applications.

Using json format has its own advantages like being light weight, ability to store complex data structures in plain text and very human readable. Earlier we have discussed about converting json to mysql data here. Now let us see how to convert mysql result set to json in php.

Create MySQL Database

Here is the MySQL Database I'm going to use as an example. Run these sql commands to create the Database.

Read Also:
CREATE TABLE IF NOT EXISTS `tbl_employee` (
  `employee_id` int(4) NOT NULL AUTO_INCREMENT,
  `employee_name` varchar(60) NOT NULL,
  `designation` varchar(30) NOT NULL,
  `hired_date` date NOT NULL,
  `salary` int(10) NOT NULL,
  PRIMARY KEY (`employee_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

INSERT INTO `tbl_employee` (`employee_id`, `employee_name`, `designation`, `hired_date`, `salary`) VALUES
(1, 'Steve', 'VP', '2013-08-01', 60000),
(2, 'Robert', 'Executive', '2014-10-09', 20000),
(3, 'Luci', 'Manager', '2013-08-20', 40000),
(4, 'Joe', 'Executive', '2013-06-01', 25000),
(5, 'Julia', 'Trainee', '2014-10-01', 10000);

Convert MySQL to JSON String in PHP

Here are the steps in converting mysql to json string with php.

Step 1: Open MySQL Database Connection in PHP

First establish connection to mysql database using mysqli_connect() function.

<?php
    //open connection to mysql db
    $connection = mysqli_connect("hostname","username","password","db_employee") or die("Error " . mysqli_error($connection));
?>

Step 2: Fetch Data from MySQL Database

After opening the connection, fetch the required table data from mysql db. Using the php function mysqli_query(), I'm going to fetch all the rows from the table 'tbl_employee'.

<?php
    //fetch table rows from mysql db
    $sql = "select * from tbl_employee";
    $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
?>

Step 3: Convert MySQL Result Set to PHP Array

Next loop through the mysql result set we got from step-2 and convert it to php array.

<?php
    //create an array
    $emparray = array();
    while($row =mysqli_fetch_assoc($result))
    {
        $emparray[] = $row;
    }
?>

Step 4: Convert PHP Array to JSON String

Next use the PHP function json_encode() to convert the php array to json string. Learn about using php json_decode() function here.

<?php 
    echo json_encode($emparray);
?>

That's it! We have successfully converted mysql to json using php. Here is the complete PHP code for it.

<?php
    //open connection to mysql db
    $connection = mysqli_connect("hostname","username","password","db_employee") or die("Error " . mysqli_error($connection));

    //fetch table rows from mysql db
    $sql = "select * from tbl_employee";
    $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));

    //create an array
    $emparray = array();
    while($row =mysqli_fetch_assoc($result))
    {
        $emparray[] = $row;
    }
    echo json_encode($emparray);

    //close the db connection
    mysqli_close($connection);
?>

Run the code and you get an output something like this.

php-mysql-to-json-response

Convert MySQL to JSON File in PHP

If you want to write the data from mysql to json file, use this piece of code at the end instead of 'echo' statement.

<?php
    //write to json file
    $fp = fopen('empdata.json', 'w');
    fwrite($fp, json_encode($emparray));
    fclose($fp);
?>
Read Also:

Find this PHP MySQL to JSON conversion tutorial useful? Like us on Facebook and never miss any of our tutorials.

Last Modified: Feb-21-2017

Insert Excel File into MySQL using PHP

On 2/20/2017 Be the first to comment!

Hi! Let's see how to insert excel file into mysql database using php. In PHP importing CSV data to MySQL is a breeze but not the same case when it comes to Excel file. Excel format is somewhat tricky to parse with php but you don't have to worry. I'm going to show you a much simpler method to achieve it. For that you'll need an excel parser library PHPExcel. This is an excellent lib and supports both 'XLS' and 'XLSX' format.

For those who don't like using third-party library here's a way to do it with core php alone. Just save your excel file as csv format, then read it with native fgetcsv() function and insert into db. Simple! But I'm not going into greater detail about the process here. As for this tutorial I'm going to focus on dealing with excel file. Come, let me show you how to read excel file and store data into mysql db with php.

How to Insert Excel File into MySQL using PHP?

Read:

The process is supposed to be like this. You have a mysql table and an excel file with some data to be stored in db. Here I'm going to assume the excel column headers matches the table fields. Now establish mysql connection, read through excel rows one by one and insert into database. Here goes the step by step process for inserting excel to mysql.

Step 1) First download PHPExcel library, unzip and move it to your root folder.

Step 2) Create necessary database and table in mysql. This is the one I'm going to use for the demo.

CREATE DATABASE IF NOT EXISTS `db_employee`;
USE `db_employee`;
CREATE TABLE IF NOT EXISTS `Employee` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(30) NOT NULL,
  `Designation` varchar(30) NOT NULL,
  `Salary` varchar(10) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Step 3) Create an excel file 'empdetails.xlsx' and add some data to it.

IdNameDesignationSalary
1Suki BurksDeveloper114500
2Fred ZupersTechnical Author145000
3Gavin CortezTeam Leader235500

Step 4) Create index.php file and add the below code to it. This is the core of the entire process. The php script loads PHPExcel library, establish connection to mysql database, read the entire excel file, store the rows in associative arrays, loop through it and insert into the database.

<?php
// set path
set_include_path(get_include_path() . PATH_SEPARATOR . "Classes/");

// include phpexcel lib
include "PHPExcel/IOFactory.php";

// mysql connection settings
$host = "localhost";
$uname = "root";
$pwd = "";
$dbname = "db_employee";

// excel file to import
$fname = "empdetails.xlsx";

try
{
    // connect to mysql
    $con = mysqli_connect($host, $uname, $pwd, $dbname);
    
    // load excel file
    $obj = @PHPExcel_IOFactory::load($fname);

    $obj->setActiveSheetIndex(0);
    $data = $obj->getActiveSheet()->toArray(null, true, true, true);

    $columns = implode(",", array_values($data[1]));

    for ($i=2; $i<=count($data); $i++)
    {
        $sql = "INSERT INTO employee ($columns) VALUES ('" . implode("','",array_values($data[$i])) . "')";
        mysqli_query($con, $sql);
    }
    echo "Successfully imported excel file to mysql!";
}
catch(Exception $err)
{
    die('Error ' . $err->getMessage());
}
mysqli_close($con);
?>

The PHPExcel parser returns excel data as array of arrays. That is, one array per row. The first row is the column headers and the subsequent ones are the actual data themselves.

Now run the file and if everything goes right, the data from excel file will be imported to mysql db and will show you some success message.

Now this is what I got - the mysql table after inserting excel data.

Read and Insert Excel File into MySQL PHP
Read:

I hope now you have got idea about inserting excel file into mysql using php. Feel free to tweak the code to fit your logic. And don't forget to share the script in social media.

Top Fingerprint Scanner Phones under Rs 8000 India 2017

On 2/16/2017 Be the first to comment!

Here are the Latest & Best Fingerprint Scanner Phones under Rs 8000 in India 2017. Gone are the days when Fingerprint Sensor has been a premium feature. Thanks to the technology improvement now you can enjoy the added security of a fingerprint scanner even on a low-budget mobile. If you think 8k budget can't get you a good smartphone then you are going to be wrong and in a good way:) I must say it's a pretty decent budget and will get you smartphone with premium features like Fingerprint sensor, 3GB RAM, 64-bit Processor, long battery life and 4G VoLTE support.

The smartphones we have recommended below are not only good in paper but in real performance. 2GB RAM is more than enough for a smartphone and with 3GB RAM you can pretty much run anything and do multi-tasking with ease. Just go through the list and grab your next smartphone with confidence.

Top 10 Best Fingerprint Scanner Phones under Rs 8000:

1. Xolo Era 2X (3GB)

Check Price

fingerprint scanner phone under 8000

Xolo Era 2X is the Best Fingerprint Sensor Phone under Rs 8000 with 3GB RAM in India 2017. It is the latest arrival to the market and got superb features like Fingerprint scanner, 4G VoLTE and the best of all 3GB RAM for a budget mobile. The phone is powered by 64-bit Quad Core Processor and Android v6.0 Marshmallow OS. It is available as 3GB and 2GB RAM variants and exclusively on Flipkart.

Key Features:

  • OS: Android v6.0 Marshmallow
  • Processor: 64-bit 1.2 GHz MTK6737 Quad Core Processor
  • Memory: 3GB RAM & 16GB ROM
  • Display: 5 inch IPS Display, HD
  • Secondary: Expandable up to 32GB
  • Camera: 8 MP Rear, 5 MP Front Camera
  • Connectivity: Dual Sim, 4G VoLTE
  • Battery: 2500 mAh Battery
  • Others: Fingerprint Sensor

(3GB) Buy From Flipkart » (2GB) Buy From Flipkart »

2. Lyf Water 7

Check Price

fingerprint scanner mobile under 8000

After the price cut, Lyf Water 7 rate has come down a lot and it's the right time to buy this excellent Fingerprint scanner phone for much cheaper price. The phone sports premium like specs and supports Fingerprint scanner, 4G VoLTE, OTG connectivity, Snapdragon 616 Octa-core Processor and 2GB RAM. Plus it has got excellent 13MP Rear Camera and AGC Dragontrail glass protected 5.5 inch Full HD display. Overall it's a smart buy at this price.

Key Features:

  • OS: Android v5.1 Lollipop
  • Processor: 1.5 GHz+ Snapdragon 616 Octa-core Processor
  • Memory: 2 GB RAM & 16 GB ROM
  • Display: 5.5 inch FHD, AGC Dragontrail glass
  • Secondary: Expandable up to 128 GB
  • Camera: 13MP Rear, 5MP Front Camera
  • Connectivity: Dual Sim, 4G VoLTE, OTG
  • Battery: 3000 mAh battery
  • Others: Fingerprint Scanner

Buy From Amazon »

3. Lyf Water 7S (3GB)

Get 36% Discount on Price

fingerprint sensor mobiles under 8000

Lyf Water 7S is the upgraded version of Water 7 and comes with improved 3GB RAM and Android Marshmallow OS. It is powered with 1.3 GHz MediaTek MT6753 Octa Core Processor coupled with 3GB RAM, 16 GB Storage which is expandable up to 64GB. Plus it has got 13MP Rear camera, 5MP Selfie camera, fast & accurate Fingerprint sensor and 4G VoLTE connectivity.

Key Features:

  • OS: Android v6.0 Marshmallow
  • Processor: 1.3 GHz MediaTek MT6753 Octa Core Processor
  • Memory: 3GB RAM & 16 GB ROM
  • Display: 5.5 inch IPS LCD Display, FHD
  • Secondary: Expandable up to 64 GB
  • Camera: 13MP Rear, 5MP Front Camera
  • Connectivity: Dual Sim, 4G VoLTE
  • Battery: 2800 mAh battery
  • Others: Fingerprint Sensor

Buy From Amazon » Buy From Flipkart »

4. Intex Cloud S9

Check Price

phones with fingerprint sensor under 8000

Intex Cloud S9 is the latest addition to its Cloud series and another good Phone with Fingerprint Sensor under 8000 Rs segment. For a 6K low budget mobile, Cloud S9 has got many great features. It runs on Android Marshmallow and powered with 64 bit Quad-core Processor and 2GB RAM. Besides it has got HD 5.5 inch Display protected with AGC Dragontrail glass, Fingerprint Sensor, 4G VoLTE support and best of all long lasting 3650 mAh battery.

Key Features:

  • OS: Android v6.0 Marshmallow
  • Processor: 64-bit 1.3GHz Quad Core Processor
  • Memory: 2GB RAM & 16GB ROM
  • Display: 5.5 inch HD, Dragontrail glass
  • Secondary: Expandable up to 32 GB
  • Camera: 8MP Rear, 5MP Front Camera
  • Connectivity: Dual Sim, 4G VoLTE
  • Battery: 3650 mAh Capacity
  • Others: Fingerprint Sensor

Buy From Amazon »

5. Swipe Elite Power

Check Price

fingerprint sensor 4000mah battery mobile under 8000 rs

Swipe Elite Power is another new comer on 8K budget segment. If you need a phone with marathon battery then we have Swipe Elite Power for you. The phone is excellent with huge 4000 mAh battery, Fingerprint scanner and 4G VoLTE support. It runs on Android v6.0 Marshmallow and packs big 5.5 inch IPS Display, Snapdragon Quad Core Processor, 2GB RAM and 16GB storage under its hood.

Key Features:

  • OS: Android v6.0 Marshmallow
  • Processor: 1.1 GHz Snapdragon Quad Core Processor
  • Memory: 2GB RAM & 16 GB ROM
  • Display: 5.5 inch IPS LCD Display, HD
  • Secondary: Expandable up to 32GB
  • Camera: 8MP Rear, 5MP Front Camera
  • Connectivity: Dual Sim, 4G VoLTE
  • Battery: 4000 mAh battery
  • Others: Fingerprint Scanner

Buy From Flipkart »

6. Coolpad Note 3 Lite

Check Price

3gb ram fingerprint scanner phone under 8000

Coolpad is the first of its kind to introduce Budget Smartphones with Fingerprint sensor and 3GB RAM and still are the best mobiles to buy in 8K range. Coolpad Note 3 Lite has got amazing specs and packs powerful 1.3 GHz Mediatek Quad Core Processor, 3GB RAM, 16GB storage, 13MP Camera, Fingerprint Scanner, OTG, 4G LTE and long-lasting 3000 mAh Battery.

Key Features:

  • OS: Android v5.1 Lollipop
  • Processor: 1.3 GHz Mediatek Quad Core Processor
  • Memory: 3GB RAM & 16GB ROM
  • Display: 5.5 inch IPS LCD Display, HD
  • Secondary: Expandable up to 64 GB
  • Camera: 13 MP Rear, 5 MP Front Camera
  • Connectivity: Dual Sim, 4G LTE, OTG
  • Battery: 3000 mAh Battery
  • Others: Fingerprint Scanner

Buy From Amazon »

7. Intex Cloud String V2

Check Price

fingerprint-sensor-phones-below-8000

Another Intex phone in our list of best fingerprint sensor mobiles under rs 8000. Intex Cloud String V2 is the most affordable smartphone with Fingerprint scanner and powered with 1.3 GHz Quad Core Processor and 2GB RAM and runs on Android v5.1 Lollipop. It sports 2.5D Curved Glass IPS display and supports 4G LTE for faster internet.

Key Features:

  • OS: Android v5.1 Lollipop
  • Processor: 1.3 GHz Quad Core Processor
  • Memory: 2GB RAM & 16GB ROM
  • Display: 5 inch IPS LCD Display, HD
  • Secondary: Expandable Upto 32 GB
  • Camera: 8 MP Rear, 5MP Front Camera
  • Connectivity: Dual Sim, 4G VoLTE
  • Battery: 2200 mAh Battery
  • Others: Fingerprint Sensor

Buy From Flipkart » Buy From Amazon »

8. Micromax Unite 4 Pro

Check Price

micromax phone with fingerprint sensor under 8k

Micromax Unite 4 Pro is one of the best selling smartphone under 8K budget. If you don't like Chinese brands, then you can go for Unite 4 Pro, a smartphone from reputed Indian brand. The phone has got all latest features like Fingerprint Sensor, 4G support, 64-bit Quad Core processor, 2GB RAM and the best part is long lasting 3900 mAh battery. And it runs on Android Lollipop but upgradable to Marshmallow which is great.

Key Features:

  • OS: Android v5.1 Lollipop (Upgradable to Marshmallow)
  • Processor: 1.3 GHz Spreadtrum SC9832A Quad Core Processor
  • Memory: 2GB RAM & 16 GB ROM
  • Display: 5 inch IPS Display, HD
  • Secondary: Expandable up to 32 GB
  • Camera: 8MP Rear, 5MP Front Camera
  • Connectivity: Dual Sim, 4G LTE
  • Battery: 3900 mAh Battery
  • Others: Fingerprint Scanner

Buy From Amazon »

9. Panasonic Eluga Tapp

Check Price

fingerprint sensor phones under 8000

Panasonic Eluga Tapp is another new arrival in the market. Priced around 6.5k the smartphone sports pretty decent features and exclusively available on Flipkart. The phone is fueled with Android v6.0 Marshmallow and powered by 1.25GHz Quad Core Processor and 2GB RAM. Plus it comes with 16GB Storage, decent 2800 mAh battery, Fingerprint sensor and the best part is 4G VoLTE support.

Key Features:

  • OS: Android v6.0 Marshmallow
  • Processor: 1.25GHz Quad Core Processor
  • Memory: 2 GB RAM & 16 GB ROM
  • Display: 5 inch IPS LCD Display, HD
  • Secondary: Expandable up to 32 GB
  • Camera: 8MP Rear, 5MP Front Camera
  • Connectivity: Dual Sim, 4G VoLTE
  • Battery: 2800 mAh battery
  • Others: Fingerprint Sensor

Buy From Amazon » Buy From Flipkart »

10. Intex Aqua View

Check Price

smartphone-with-fingerprint-scanner-below-8000-rs

Intex Aqua View is another good low-budget alternative in our list of fingerprint sensor phones under rs 8000/-. The phone is powered with MediaTek MT6735P Quad Core Processor and 2GB RAM and packs 16GB Storage, High definition 5" IPS display, 8MP Camera with Dual-LED flash, Fingerprint scanner and 4G VoLTE connectivity for fast internet.

Key Features:

  • OS: Android v5.1 Lollipop
  • Processor: 1 GHz MediaTek MT6735P Quad Core Processor
  • Memory: 2GB RAM & 16GB ROM
  • Display: 5 inch IPS Display, HD
  • Secondary: Expandable up to 32 GB
  • Camera: 8MP Rear, 5MP Selfie Camera
  • Connectivity: Dual Sim, 4G VoLTE
  • Battery: Li-ion 2200 mAh Battery
  • Others: Fingerprint Scanner

Buy From Amazon » Buy From Flipkart »

Read Also:

That makes for our recommendations of top 10 best fingerprint sensor phones under 8000 rupees. I hope you like this list. Please share this in social media and help your friends to choose their next smartphone.

5 Best Ultrabooks for College Students 2017 [TOP PICKS]

On 2/14/2017 Be the first to comment!

Best Ultrabooks for College Students - Ultrabooks are high-end laptops that are powerful, sleek, light-weight and are convenient to carry around for a college student. Especially if you are an IT, Computer science, Engineering, Architecture or Media majors then definitely you'll need efficient ultrabooks to complete demanding school tasks.

And I must say buying a laptop is not an easy job. It's an expensive investment of your college life and definitely expected to last throughout your college years. I was in your shoes once and expected my laptop to be powerful but compact at the same time. I found out Ultrabooks are the right choice and never regretted buying one.

So below I have hand-picked some of the best ultrabooks on the market that are budget-friendly, compact, speedy and has longer battery life. Read through it and decide the best ultrabook for your college needs.

Top 5 Best Ultrabooks for College Students (2017):


1. ASUS ZenBook Flip

Check Price

best ultrabook for college students

ASUS ZenBook Flip is our #1 recommendation for best ultrabooks for college students. ZenBook Flip is affordably priced and looks sleek and beautiful. It packs powerful 6th generation Intel Core M Processor, 8GB RAM and abundant 512GB SSD to store all your music, videos, games and school related work. The ultrabook is very good at multi-tasking and you won't get tired looking at its 13.3 inch Full HD screen. Plus ZenBook Flip is a 2-in-1 hybrid model and touchscreen enabled so you can flip the screen and use it as a tablet to watch movies or play games. Above all, the ultrabook is very-thin and light-weight so you can tuck it easily in your backpack and carry it to school every day.

Get It Now From Amazon

2. Dell XPS 13

Check Price

best ultrabook for college 2016

Dell XPS 13 has everything in it a college student wants in a laptop. It comes pre-installed with Windows 10 OS and looks absolutely gorgeous and highly portable. There is no questioning about its performance. The latest Dell XPS 13 is powered with 7th generation Intel Core i5 7200U Processor, 8GB RAM, 256GB SSD storage, 13.3 inch Infinity display that rivals Apple's Retina displays. As a college student, we all know how much time you have to spend writing in laptops. And Dell XPS is the perfect choice for it with its eye-friendly display and ergonomic keypad. But the unique feature of this ultrabook is the marathon 14 hours of battery life. So students just forget the charger and lug it anywhere you go.

Get It Now From Amazon

3. ASUS Zenbook UX330UA

Check Price

best ultrabook under 700 dollars

If your budget is not very high and need something in mid-budget, then I'll recommend ASUS Zenbook UX330UA for college. The laptop boasts pretty cool features for a budget device which is under $700. It comes with 7th generation Intel Core i5 Processor, 8GB of RAM, 256 GB of SSD Storage and 13.3 inch Full HD screen. It has got so much power to complete all your school stuffs. Plus it weighs just 2.6 lbs and neatly fits in your school backpack - a breeze to carry away to college every day.

Get It Now From Amazon

4. Apple MacBook Air 13-inch

Check Price

best ultrabook for programming students

A vast group of people loves Apple products and it's no wonder considering their design and performance. Slim and classy, Macbooks defines the term ultrabooks. You can't go wrong with a Macbook. Ultra-slim design to go with solid core performance and fantastic battery backup, Macbook is one of the best laptops you can get till date. If your budget allows go for it. In my opinion, college students, especially those who major Engineering, IT, Computer science or Programming should definitely get a feel of working in Mac OS which will be helpful in future.

Get It Now From Amazon

5. Lenovo Yoga 3 Pro

Check Price

best 2 in 1 convertible laptops for college use

Lenovo Yoga 3 Pro is another good mid-range 2-in-1 ultrabook. The laptop is popular among college students since it is very flexible and portable. You can just flip around 360 degree and use it as a touchscreen tablet. It looks pretty and comes with 13.3 inch QHD touch screen display, Intel Core M Processor coupled with 8GB DDR3L, 256GB SSD Storage and pre-loaded Windows 10 Home OS. Overall it is a very stylish ultrabook and easy to carry around since it weighs just 2.3 lbs.

Get It Now From Amazon

So that was all our recommendations for best ultrabooks for college students in 2017. We are sure that these ultrabooks are hard-core performers and cope up well with your college work and every day use. You are good to go with any of them but your budget and requirement is what going to decide which one suits better. Please share this article with your friends and help them find a good ultrabook for college.

Also Read:

Contact Form

Name

Email *

Message *