How to Delete a file in PHP
In the last tutorial, we wrote to a log file called “log.txt” in PHP. Now we use PHP to delete this file. Simple do… unlink(‘log.txt’); in PHP. And the file will...
read moreTutorial on How to Write to a File in PHP
In this tutorial, we will show you how to write to a log file in PHP. Here is a basic function we called “writelog” which takes a $msg message string to be written into a log file...
read moreTutorial using PHP to Query MySQL
In this tutorial, we will use PHP to query a MySQL database. For the purpose of this example, suppose we want to query the last 5 posts from a WordPress MySQL database. We will need to know the...
read moreFile Upload in PHP Tutorial
In this tutorial, we will build a file upload form in PHP to upload an image file to the web server. In the process, we will perform a few security checks to prevent file upload abuse. 1. Start...
read moreUsing Random Form Token to Help Protect Against CSRF
Suppose we have the following form in index.php … that will POST to do.php to do something. To help protect against CSRF (cross-site request forgery), in do.php we have to make sure that it...
read moreHandling international characters in PHP
If you need to handle international characters in PHP, the “PHP The Right Way” says to do something like this … The mb_internal_encoding(‘UTF-8’) function tells PHP to...
read moreReplace ShortCode using PHP
Here we have a data.html file with two shortcodes marked by square brackets: [myimage.jpg] and [myimage2.jpg] … I want to write PHP code to search and replace with these… <a...
read moreAdding captcha on PHP forms
Continuing from our previous tutorial, in this tutorial we will add a captcha on our PHP form. We will use the “Securimage” (spelled with no e) captcha from phpcaptcha.org. To get the...
read moreSecurity checks on contact forms
PHP contact forms are very common. But you should make some security checks before sending the contents out via mail. Or better yet, use some third party forms or WordPress form plugins. But if...
read moreAll contents are opinions and are copyrighted and may contain display ads and ad links for which site may receive revenues from.
See Terms of Use and Privacy Policy.