Monthly Archives: August 2011

Email syntax validation using javascript

We should validate the syntax of email entered in the form in the client side itself to save unnecessary server process to validate the email. It can be done using javascript. Consider below form. onSubmit event of Form is calling a

Posted in Javascript Tagged with: ,

PHP function to get the ID generated from the previous INSERT operation in mysql

It is necessary to get the ID (auto increment field) of a row inserted into a mysql table if the table is having any parent-child relationship with one or more child tables. For example, assume that we are entering questions

Posted in MySQL, Php Tagged with: ,

Displaying Random records from MySQL database table

Sometimes we may need to display some value selected from database table which is having many records. In this situation we can select them randomly to improve user experience. It applies to displaying random advertisements, testimonials, quotes,images,background colors and news.

Posted in MySQL, Php Tagged with: ,

Displaying vertical scroll bar dynamically in HTML elements

Vertical scroll bar in HTML controls/elements/tags such as TEXTAREA and SELECT will be useful if the element has more content/items. But always showing Vertical scroll bar will be occupying some space in the page unnecessarily. So the best way is,

Posted in Html Tagged with: ,

Allowing Users to Change attribute of the HTML tag using javascript

Normally we will set values for attributes of HTML tag during design time. But each user will be expecting different values. For example “scrollamount=’2′” set in marquee tag may not be suitable for all users. Some people will expect more

Posted in Html, Javascript Tagged with: ,

How to get last row from database table

If you want to find last row in a table in your database there is no need to loop through to get the last record .Mysql provides you with a provision for that . It is easy to find last

Posted in MySQL Tagged with: ,

PHP code for preventing session hijacking

Session security is a sophisticated topic, and it’s no surprise that sessions are a frequent target of attack. Most session attacks involve impersonation, where the attacker attempts to gain access to another user’s session by posing as that user. The

Posted in Php Tagged with: ,

Resolving delimiter issue in PHP

A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character. Often used delimiters are forward slashes (/), hash signs (#) and tildes (~). The following are all examples of valid delimited patterns. /foo bar/ #^[^0-9]$# +php+ %[a-zA-Z0-9_-]% Server side coding can

Posted in Php

Getting current Page Name in PHP

If you want to get the current page name , php provides you with an inbuilt function $_SERVER[‘PHP_SELF’]. $_SERVER[‘PHP_SELF’] can be used to obtain the current name in the php.It will be necessary for us to use this $_SERVER[‘PHP_SELF’] for

Posted in Php Tagged with: ,

Basics of Session and Cookies

We know that Webpages are getting displayed using stateless Protocol. So there should be someway for keeping the session of the user navigating the webpages within a website. Session variables and Cookie variables can be used for this purpose. Basically Session variables

Posted in Basics of Internet, Html, Php Tagged with: ,