PHP Script Examples

The following script examples are intended to demonstrate various techniques in PHP. We pick the most used PHP Scripts, for instance, creating a user registration and login function and the explanation of how they work. As a result, you can take a look at some tips on how to elegantly solve such a problem. You are welcome to use all the scripts in these articles for your website.

Login script

This example shows you how to easily implement a registration and login feature using MySQL and Sessions.

Send emails with attachment

This code example explains how you can conveniently send emails with attachments.


This article will explain how to create a simple guestbook for your website. Each step is described in detail so you can understand the principle as simple as possible.

Create PDF via PHP - PDF-Bill

Using the library TCPDF, you can easily create PDF-documents via PHP, for example, an invoice, without additional software. For this purpose, the content of the PDF is defined as HTML code and then translated into a PDF document.

Counter with Reload Lock

This is a simple counter. The number of page views is counted and output. Multiple calls from a visitor are ignored.

Contact form

Script example for a form mailer. This retrieves all fields of a contact form, formats them and sends them by e-mail to a specified recipient.

Generate log files with PHP

This script explains how you can log various information such as the IP, the accessed page and the visitor's browser in a log file.

Identifying URLs in a text

A common feature found on almost any website is the automatic identification of URLs and email addresses in the text and the automatic conversion of these into correspondingly clickable hyperlinks. This tutorial will show you how it works with PHP and regular expressions.