Blog Archives

you can learn here basics about Php.

Sample PHP code for creating forgot password feature in any website

Most of the websites will require the users to register them for getting username/password which can be used for logging into their website. It is very common that the users forget their password. So, the websites should allow the users to

Posted in MySQL, Php Tagged with: ,

PHP code for listing files in a Folder

If you want to list all the files in a folder for some purpose here is a php code for that .You can use this below code to list all the files in a folder

Posted in Php Tagged with: ,

Setting UserAgent for php curl session to avoid 500 Internal Server Error

We are using below function for getting webpage content using curl module of php. function getmethod_request($ch,$ckfile,$urlValue) { curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); //The name of the file containing the cookie data. The cookie file can be in Netscape format, or just plain

Posted in Php Tagged with: ,

Parsing webpage using php DOM

PHP is having DOM functionality for parsing webpage by considering the HTML content of the webpage as XML data. If you assign the $data with the HTML content of the webpage, below code will load the HTML content in DOM

Posted in Php

Removing Last Character in a String

In PHP, we will be requiring to remove the last Character from a string variable. For example, consider below query. select * from employees where employee_id in (1,2,5,7) Assume that the employee_id values 1,2,5,7 should be dynamically collected from a

Posted in MySQL, Php 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: ,

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: ,