This tutorial explains how to use checkboxes in PHP to get values which are checked by the user. Use checkboxes in PHP and insert the values into MySQL. Usually using other HTML form controls with PHP is easy. The input element is assigned a name and values entered can be retrieved using GET or POST method. But in the case of checkboxes it might be ticked or left empty also. Using checkboxes in PHP involves setting the name attribute of all checkboxes to a common name with an empty square bracket denoting an array. When the form is submitted the vales of the items checked are send as an array which is explained hereContinue Reading…
Multiple submit buttons in PHP
This tutorial explains how to use multiple submit buttons in a HTML form and have PHP handle it. Usually a HTML form has only one submit button but there are situations when you might need to use more than one submit buttons and have PHP check which button has been pressed and an action to be done according to the button pressed. Having multiple submit buttons and handling them through PHP is just a matter of checking the the name of the button with the corresponding value of the button using conditional statements.Continue Reading…
How to display IP Address in PHP
PHP can be used to get the IP Address of a website visitor, IP address of the server hosting the website and resolve the IP address to get the hostname a.k.a reverse DNS records. PHP has predefined $_SERVER array variable using which IP addresses of both visitors and host can be retrieved. The gethostbyaddr() function is used to find out the hostname. The indices REMOTE_ADDR and HTTP_HOST contain the visitor IP address and host IP addressContinue Reading…
PHP Captcha Tutorial
Create a PHP captcha using simple PHP image handling functions. Creating a PHP Captcha image explained. The only difference between a captcha and a normal text written on an image is the former generates random strings and places it crookedly on the image making it difficult for bots to find out. This PHP captcha tutorial will make use of six image functions imagecreate(), imagecolorallocate(), imageline(), imagettftext(), imagepng(), imagedestroy(). You can feel free to modify it and add more functions to bring visual effects. For PHP Random string generation see the previous article.Continue Reading…
PHP random string generation
Generate a random alphanumeric string containing both uppercase and lowercase characters in PHP. The rand() function in PHP generates a random number we’ll be using this function to generate a random alphanumeric string. A variable should be declared containing all the alphabets in English both uppercase and lowercase (A-Z and a-z) and numbers from 0-9. The concept here is to randomly pick a character from the string containing all the characters and assign it to a variable. Each time this process is done the currently randomly selected character is concatenated with the previously generated characters. This should be done as many times the length of the random string required. For this a looping statement can be used.Continue Reading…
PHP error_log .htaccess
The PHP error_log setting specifies in which file the PHP script errors are logged. This setting is usually specified in the PHP configuration file php.ini which points to a file in which errors of all PHP scripts on that server are logged. It can be modified per directory basis to maintain separate logs for different set of scripts. For users on shared hosting account it is a bonus feature of being able to modify the error_log setting. Normally the error log is a single file for an entire server which is stored in one central place which is only accessible by the root user. But by modifying the error_log setting using htaccess you can have a separate error log for your web hosting account. The php_value error_log requires the php_flag log_errors to be On.Continue Reading…