24 Aug 2015

MySQL OTHERS

PHP MySQL Secure Registration Page

Create Registration Form PHP MySQL

Registration page is basically a page having several fields that the user provide in order to get register themselves for that site. Registration page contains various details about user , that user had to fill Some fields are mandatory and some are optional.
We can apply several validations on registration page using java-script on clicking submit button all the information for that particular user are stored in the database. For every new user he need to register himself and for existing users he just need to login.
In above example there are 4 fields: name , password , mobile number , gender
if these fields are found to be empty it will show error. if the existing user try to register with
same information then error is reported.

Create Database and Table

PHP Script

Registration Form(HTML Script)

In above example there are 4 feilds: name , password , mobile number , gender
if these feilds are found to be empty it will show error. if the existing user try to register with
same information then error is reported.

PHP MySQL Secure Login Page

Create Login Form PHP MySQL

Login page is basically a page having several fields that the user provide in order to get
access of the home page of that site. if there is a previously registered user whose details
are stored in the database and that particular user want to login then the details provided by him
on the login page are cross checked with the fields in the database respectively. if the details are
found to be correct the user is considered to be a valid user .
as we already know that http is a stateless protocol and it doesn’t identify any previous user, that’s why
we maintain the session for that particular user.

Select Database and Table(Saved users data inside table in previous example)

PHP Script(for dynamic login)

Login Form(HTML Script)

In the above example
first connection to database is created after that id and password are entered by the user and as he click on the signing buttons these fields are cross checked with values in the database by using MySQL_query( ) . if user is authenticated then he will be redirected to homepage otherwise it show error message.

PHP MySQL Pagination

How to use Pagination in PHP MySQL

MySQL SELECT query may display the thousands of records from the database.
TO show these thousands of records in a single page is not possible. for that purpose we use the concept of MySQL pagination. In Mysql pagination we divide results into many pages.Basically it is the method of showing somewhat lesser results on page instead of putting them all together on a single page.
Suppose there are 15 records in a table. 5 records on each page are displayed by using pagination.
each of the 3 pages will have 5 records.Each time we click on next page the next 5 records will got
displayed and the previous 5 records will get removed.
Below is the Example.
In above example there is paginate function which has two arguments , one is the connection of database
and other is Limit variable which is basically the number of records on each page.
FOUND_ROWS() function return the number of rows from the table in the absence of limit clause.

Show 5 records on each page

There are 15 records inside userinfo table. Show only 5 records on each page.(use Pagination)
save as paginate.php

Select records from userinfo table(Total records are 12). show 5 records on each page.

In display.php we have included the paginate.php and the results fetched by it are shown in a tabular form. The records in the result variable are fetched by mysql_fetch_array() function which is put in a while loop to display all records.
The information fetched by the display function is subdivided into pages and each page contain maximum of 5 records.