Username availability check using Codeigniter, AJAX and MySQL

This tutorial will show you how you can check username availability using Codeigniter, AJAX and MySQL. Sometimes we need to check username availability instantly before a user presses the submit button after filling a long-sized signup form. In this case we can use AJAX technique with any server side technologies like PHP, Codeigniter, Servlet, Struts, JSF, Spring etc. for checking whether the input username is avaialable for creating new user account or it has already been taken by someone else. So if we give instant result to the user for username availability then sometimes it makes more sensible than while pressing the submit button and goes top of the signup form to rectify the username input field if input username is not available. So after finishing this example “username check availability using Codeigniter, AJAX and MySQL” you will be able to apply the same logic to any server side technologies.

Continue reading “Username availability check using Codeigniter, AJAX and MySQL”

Save Files to MySQL using PHP

We have seen file upload using PHP in previous tutorials PHP file upload but in this tutorial we will see how to save files to MySQL database using PHP.

You may be wonder why you would need to save file content into database rather than just into the file system. In situations where PHP application needs to put entire file then the preferred method would be to put the file into server’s file system and save the file path into the database.

However in situations, where an application needs to save the entire file content into database along with other data. In such cases you have to put the file content into MySQL’s BLOB data type field.

Continue reading “Save Files to MySQL using PHP”

Multi-step Registration form using Codeigniter, MySQL, jQuery

Sometimes we need to capture lots of user details during registration process and as a result we got long forms on web page. So the best solution is to break the form into smaller logical section and present it into a multi-step registration form. This type of mult-step registration form always improves usability on web page comparing to very long form.

I am going to explain how to convert very long form into multi-step registration form using Codeigniter, MySQL and jQuery.

Continue reading “Multi-step Registration form using Codeigniter, MySQL, jQuery”

MySQL procedure to split a column into rows using a delimiter

Suppose, there is a table called sometbl and has the following data into it.

CREATE TABLE sometbl ( ID INT, NAME VARCHAR(50) );
INSERT INTO sometbl VALUES (1, 'Smith'), (2, 'Julio|Jones|Falcons'), (3, 'White|Snow'), (4, 'Paint|It|Red'), (5, 'Green|Lantern'), (6, 'Brown|bag');

Therefore for (2), example rows would look like >> “3, white”, “3, Snow” …

Continue reading “MySQL procedure to split a column into rows using a delimiter”

MySQL error – Access denied for user ‘root’@’localhost’

If you get an error message like this:

Access denied for user: 'username@localhost' (Using password: YES)

then the problem is that user can not access the database. This can have several causes:

First of all, you use the correct name and password of your MySQL user for connecting to your database.

Secondly, make sure the your database user has the password and it is not blank. If your database user does not have any password then create a password for your database user by following the steps below.

Start the MySQL server instance or daemon with the --skip-grant-tables option (security setting).
Continue reading “MySQL error – Access denied for user ‘root’@’localhost’”