Simple Form with PHP and Ajax


In this post I will explain how to work with a simple form and the submitted form data is handled by PHP. I think this may helpful for the beginners.

In this example I have used javascript to validate the form and used bit of ajax.

By using ajax I am checking the database if the username or the email is already been used. If so an error message will be shown.

I hope to keep this example very clear and simple as much as possible.

I am using MySql database in my example and to run this example first you need to create a database, named “form” and in that database create a table, named “register” which has three columns as “name”, “username” and “email”.

Here you have the sql for that, just copy and paste the code in your mysql prompt and run it.

CREATE DATABASE `form`;
USE `form`;
CREATE TABLE IF NOT EXISTS `register` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(256) NOT NULL,
  `username` varchar(256) NOT NULL,
  `email` varchar(256) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

SyntaxHighlighter.all();

Posted in Ajax, Javascript, PHP, PHP & Javascript, Uncategorized | Leave a comment

WELCOME YOU ALL..!!!

Hi Friends,

In this blog site I thought to help my friends, who interested in programming. Basically I publish code pieces of php, javascript, joomla, Mootools and JQuery. These codes are completely written by me and feel free to use anywhere in your work. I invite you all. Happy Programming and good luck.

Please note that this blog is just started and I will keep posting many of my codes continuously. So don’t forget to visit every day and to check what’s new here or just subscribe you in my rss feeds. Don’t forget to leave your feedbacks which may helpful to improve the site and I really appreciate them.

Thank you.

Posted in Uncategorized | Leave a comment