Browsing category PHP

MySQLi: Handling MySQL databases in PHP

MySQLi (MySQL Improved) is the new driver which is used to connect to MySQL databases exclusively in PHP. This improved extension has a lot of advantages over the old mysql_query statements. You can take advantages of the new functionality when you upgrade from mysql to mysqli. One of the major advantage you can get is

Connecting to MySQL Databases using PDO in PHP

To connect to MySQL databases in PHP, the age old mysql_connect API is no longer used. It has been deprecated and will not be supported in future PHP versions. So, there are recommendations everywhere for us to use either PDO (PHP Data Object) or mysqli_connect. Using PDO (PHP Data Objects) PDO supports multiple database types.

Uploading Files in PHP using Forms

When you have to allow users to upload files using HTML forms and PHP, it is quite simple. All you have to use is $_FILES super global and it will upload the file. You can also set additional options like giving the uploaded file a file name and selecting the upload directory. You can also

Form Handling in PHP – POST vs. GET

PHP is perfect for handling the data collected by HTML forms. You can process the forms and use the data in PHP. The data can then be emailed or stored in a database. The information then can be processed using POST or GET method. The method is specified when creating the form in HTML. Depending

PHP Super GLobal Variables like $_SERVER

In PHP there exists what is known as super global variables. These variables are usable from anywhere or any php file or script. They do not need to be pre-defined. Their values also need not be specified. They are used to hold certain values such as ip addresses, domain names, referrers etc. These superglobals are

Cookies and Sessions in PHP

Cookies are used to store values and information. They are stored by the browser on the client’s side. So you can access cookies from multiple pages of your website. When they are stored, the data is URLencoded and they are decoded during retrieval. While setting a cookie, you can set a name, value, expiration date

Sending Email in PHP Using mail() Function

If you have to send email in PHP, then simply use the in-built mail() function. It must be enabled by your PHP web host. It normally is. If you need to see whether PHP mail is activated or not, just try the simplest example from below. If the mail is delivered, then the host supports