Tutorials on Web Development, Programming, and Web Design

How to Delete a file in PHP

In Tutorials

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 more

Tutorial on How to Write to a File in PHP

In Tutorials

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 more

Tutorial using PHP to Query MySQL

In Tutorials

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 more

File Upload in PHP Tutorial

In Tutorials

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 more

Using Random Form Token to Help Protect Against CSRF

In Tutorials

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 more

Handling international characters in PHP

In Tutorials

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 more

Replace ShortCode using PHP

In Articles

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 more

Adding captcha on PHP forms

In Tutorials

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 more

Security checks on contact forms

In Tutorials

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 more

Learn Web Tutorials is hosted by Hostmonster and design based on Wordpress template by Elegant Themes
All 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.