So, you want to send automated email messages from your PHP application. This can be in direct response to a user's action, such as signing up for your site, or a recurring event at a set time, such as a monthly newsletter. Sometimes email contains file attachments, both plain text and HTML portions, and so on. To understand how to send each variation that may exist on an email, we will start with the simple example and move to the more complicated. More...
Sometimes, you might want to get the current page URL that is shown in the browser URL window. For example if you want to let your visitors submit a blog post to Digg you need to get that same exact URL. There are plenty of other reasons as well. In this tutorial we will show how you can do that. More...
Regular expressions are a powerful tool for examining and modifying text. They enable you to search for patterns within a string, extracting matches flexibly and precisely. This tutorial gives a brief overview of basic regular expression syntax and then considers the functions that PHP provides for working with regular expressions. More...
Array does not have to be a simple list of keys and values; each array element can contain another array as a value, which in turn can hold other arrays as well. This way, you can create a multi-dimensional array. In this article principles of using multidimensional arrays are explained and source code defining multidimensional array and displaying the array values on the web page is given. More...
Client side form validation usually done with javascript. For the majority of your users, JavaScript form validation will save a lot of time up front. More...
In this article we demonstrate several ways to create Microsoft Word and Excel documents, and also CSV files using PHP. Learn how to create files using HTTP headers, COM objects, OpenOffice templates, fputcsv function. More...
PHP makes uploading files easy. You can upload any type of file to your Web server. In spite of security issues that should be addressed before enabling file uploads, the actual mechanisms to allow this are straight forward. In this tutorial we will consider how to upload files to some directory on your Web server. We will also discuss security issues concerned with the file uploading. More...
If you're storing anything in MySQL databases that you do not want to lose, it is very important to make regular backups of your data to protect it from loss. This tutorial will show you two easy ways to backup and restore the data in your MySQL database. You can also use this process to move your data to a new web server. More...
This tutorial will describe how to create thumbnail images on the fly using PHP. Furthermore you will learn how to process a whole folder of images and create their thumbnails. Since this requires the GD library, you will need an installation of PHP with at least GD 2.0.1 enabled. More...
CAPTCHA is a simple test to determine if a user is a computer or a human. It is used to prevent spam abuse on the websites. The goal of this tutorial is to demonstrate how to make your own simple CAPTCHA protection using PHP and AJAX technologies. More...
If you are developing a password-protected web site, you have to make a decision about how to store user password information securely. This article will show you how to encrypt user passwords with md5 algorithm and how to start using encrypted passwords if you already have users' database ready. More...
JavaScript is mainly used as a client side scripting language, while PHP is a server side technology. Unlike Java or ASP.Net, PHP doesn't have tools to make it work client side. That is why you need to combine JavaScript and PHP scripts to develop powerful web-applications. More...
Before you can get content out of your MySQL database, you must know how to establish a connection to MySQL from inside a PHP script. To perform basic queries from within MySQL is very easy. This article will show you how to get up and running. More...
Creating images on the fly can be a very useful skill. In this tutorial we will show you how to get quite interesting and useful effects using image handling functions. We will review two practical tasks: creating security images (captcha) on the fly and building a bar chart using numerical values retrieved from MySQL database. More...
All elements (except hidden elements) in the HTML form are part of the form's tab order. When the user presses the Tab key, the browser shifts the input focus from element to element in order the elements appear in the HTML code. However, sometimes you want the tab order to flow a little differently. More...
In this article we demonstrate how to generate and send emails with ASP using CDOSYS - Microsoft's improved interface for SMTP email. You will learn how to send text and html emails, emails with attachments, use a remote server, load recipients from a database, set the priority / importance of an email and request a read/return receipt. More...
Normally when you have a form with several text input fields, it is undesirable that the form gets submitted when the user hits ENTER in a field. Some people are pressing the enter key instead of the tab key to get to the next field. They often do that by accident or because they are accustomed to terminate field input that way. If a browser regards hitting ENTER in a text input field as a request to submit the form immediately, there is no sure way to prevent that. More...
Arrays can be used in many ways to store and organize data quickly and efficiently. It is one of the more useful data types available to any programming language. This article describes the basics to create and make operations with indexed, associative, and multidimensional arrays. More...
One of the best features of PHP is possibility to respond to user queries or data submitted from HTML forms. You can process information gathered by an HTML form and use PHP code to make decisions based off this information to create dynamic web pages. In this tutorial we will show how to create an HTML form and process the data. More...
Pretty often you need to run a couple of queries against your MySQL database on the client's web server. Usually phpMyAdmin does the job well but there are
situations when you just need to upload something to the server and open in the borwser, without any configuration steps.
Welcome Bike, lightweight phpMyAdmin replacement. If you already have a CMS installed on the web server (WordPress, Drupal, Joomla), simply upload Bike to CMS's subfolder and open it in the browser.
As soon as you've decided to implement BBCode in your software product, we propose you to examine the jquery.BBCode plugin. This Jquery library plugin is a simple BBCode editor with preview option, which can be easily placed on any website. More...
As is necessary for any language, PHP has a complete set of directory support functions. PHP gives you a variety of functions to read and manipulate directories and directory entries. Like other file-related parts of PHP, the functions are similar to the C functions that accomplish the same tasks, with some simplifications. This tutorial describes how PHP handles directories. You will look at how to create, remove, and read them. More...
Sometimes when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. In this tutorial we will look at two structures: if...else and switch statements. In this tutorial we will will show you how to use both of them. More...
Your users probably asked you to add an option to export the whole database to SQL file. This can be done in phpMyAdmin or Navicat of course but your users want something simpler than that. More...
The Xdebug is the extension for PHP that helps debugging PHP scripts by providing a lot of valuable debug information. Using the Xdebug you can debug your scripts in the Notepad++ and other PHP IDEs. More...
Sometimes it can be useful to have a dump of the current database schema. This script reads the schema from a MySQL database and outputs XML that describes the schema. More...
Arrays can be used in many ways to store and organize data quickly and efficiently. It is one of the more useful data types available to any programming language. This article describes the basics to create and make operations with indexed, associative, and multidimensional arrays. More...
Many web developers consider PHP as a second class language. The truth is, as DHH puts it: "You can build the best web application in the world with any language you want".
We are here not to start a religious war but to help beginner PHP developers get better. Here is the some of the best advice from season PHP programmers.
First steps
Get into the habit of commenting your code thoroughly from the outset, your future self will thank you https://www.phpdoc.org/
Ignore any online tutorials, stack-overflow solutions or any other PHP code snippets on the internet that are older than 3 or 4 years (use Google's advanced search date tools to filter out older content). PHP had evolved dramatically in the last few years, and much of what is out there is wrong, insecure and bad practice.
More...
Sometimes you need to add an extra protection to password-protected website. This article explains how access to the login page can be restricted after three unsuccessful login attempts. This schema uses visitors IP address to store log attempts in the database and block access to login feature for 30 minutes after third unsuccessful attempt. More...
If you are developing a password-protected web site, you have to make a decision about how to store user password information securely. This article will show you how to encrypt user passwords with md5 algorithm and how to start using encrypted passwords if you already have users' database ready. More...
It is often necessary to arrange the elements in an array in numerical order from highest to lowest values (descending order) or vice versa (ascending order). If the array contains string values, alphabetical order may be needed. Sorting a one-dimensional arrays is quite easy. More...
The power of Active Server Pages comes through when we tie databases to our web sites. To connect to a database, ASP uses what is called ActiveX Data Objects, or ADO for short. ADO comes with ASP, and can be used easily from your ASP pages. In this tutorial we will show you how to connect to our Access database and retrieve all the records from the table. More...
Sometimes, you might want to get the current page URL that is shown in the browser URL window. For example if you want to let your visitors submit a blog post to Digg you need to get that same exact URL. There are plenty of other reasons as well. In this tutorial we will show how you can do that. More...
A variable is a holder for a type of data. So, based on its type, a variable can hold numbers, strings, booleans, objects, resources or it can be NULL. In PHP all the variables begin with a dollar sign "$" and the value can be assignes using the "=" operator. This article shows the basic idea on how to use variables in PHP, along with examples, and descriptions of the examples. More...
Sometimes when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. avaScript supports two conditional statements: if...else and switch. In this tutorial we will will show you how to use both of them. More...
PHP performs several types of repetitive operations, called "looping". Loops are set of instructions used to repeat the same block of code till a specified condition returns false or true depending on how you need it. This tutorial shows the basic idea on how to use looping statements in PHP, along with examples, and descriptions of the examples. More...
The great advantage of ASP is possibility to respond to user queries or data submitted from HTML forms. You can process information gathered by an HTML form and use ASP code to make decisions based off this information to create dynamic web pages. This tutorial demonstrates how to create an HTML form and process the data. More...
Sometimes instead of just adding your javascript to the page and having the browser perform the tasks as soon as the script is read, you might want your javascript to be performed only upon the detection of a certain event. A function is a block of code which can be called from any point in a script after it has been declared. It is basically a compartmentalized JavaScript designed to accomplish a single task. Furthermore, JavaScript written into functions will not be performed until you specifically ask for it. This way you gain complete control of the timing. Functions are useful because they contribute to rapid, reliable, error-reducing coding, and increase legibility by tiding up complicated code sequences. More...
In Access, the Replace function returns a string in which a sequence of characters has been replaced with another set of characters a specified number of times. More...
A variable's purpose is to store information so that it can be used later. A variable is a name, or identifier, that represents some data that you set. This article shows the basic idea on how to use variables in JavaScript, along with examples, and descriptions of the examples. More...
In SQL, there are two uses of the IN keyword, and this section introduces the one that is related to the Where clause. When used in this context, we know exactly the value of the returned values we want to see for at least one of the columns. More...
JavaScript performs several types of repetitive operations, called "looping". Loops are set of instructions used to repeat the same block of code till a specified condition returns false or true depending on how you need it. This tutorial shows the basic idea on how to use looping statements in JavaScript, along with examples, and descriptions of the examples. More...
The Having clause is optional and used in combination with the Group By clause. It is similar to the Where clause, but the Having clause establishes restrictions that determine which records are displayed after they have been grouped. More...
There are two types of VBScript arrays - static and dynamic. Static arrays remain with fixed size throughout their life span. To use static VBScript arrays you need to know upfront the maximum number of elements this array will contain. If you need more flexible VBScript arrays with variable index size, then you can use dynamic VBScript arrays. VBScript dynamic arrays index size can be increased/decreased during their life span.
Further in this article author explains how to create static arrays and how to create and resize dynamic arrays, giving working examples. More...
In Access, the Switch function evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True. More...
ASP performs several types of repetitive operations, called "looping". Loops are set of instructions used to repeat the same block of code till a specified condition returns false or true depending on how you need it. This tutorial shows the basic idea on how to use looping statements in ASP, along with examples, and descriptions of the examples. More...
PHP stands for Hypertext Preprocessor and is a server-side language. This article introduces you to PHP. You will learn basic PHP syntax, what it looks like, and possibilities that PHP provides you with. More...
Arrays do not have to be a simple list of keys and values; each location in the array can hold another array. This way, you can create a multi-dimensional array. The reason you may use this type of array is when you have records of each item. For example, car, year, price,... and you want display one record at a time.
In this article principles of using two-dimensional arrays are explained and source code defining two-dimensional array and displaying the array values on the web page is given. More...
A function is a block of code which can be called from any point in a script after it has been declared. It is basically a compartmentalized PHP script designed to accomplish a single task. Functions are useful because they contribute to rapid, reliable, error-reducing coding, and increase legibility by tiding up complicated code sequences. More...
Connection strings are string variables which contain database connection information and then passed to ADO which will interpret them and act accordingly. Since there are going to be passed to ADO, they need to be in a comprehensible for ADO format. This tutorial was created as an easy reference of various ADO and ADO.NET connection strings for the most popular database types. More...
This tutorial will provide you with a quick look at the more important VBScript functions. They include functions for type checking, date manipulation, string manipulation, formatting, math, and more. More...
Sometimes when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. There are two types of conditional statements in ASP: if...then and select case. In this tutorial we will will show you how to use both of them. More...
A cookie is a message given to a Web browser by a Web server. The browser stores the message in a small text file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, the cookie is sent back to the server too. The main purpose of cookies is to identify users and possibly prepare customized Web pages for them. In this tutorial you'll learn about using Cookies in PHP. More...
Perhaps, you face a task to show slightly different information to different website visitors. We decided to address this issue by implementing a generic JavaScript solution. More...
Now that you have installed all the support software for running PHP, you are ready to learn how to do a PHP script. Writing a PHP script is very simple. No special software is needed, except a text editor like Notepad in which the script is written. More...
You can write functions in ASP similar to the way you write them in Visual Basic. It is good programming practice to use functions to modularize your code and to better provide reuse.
This article explains benefits of using functions and subprocedures, shows difference between them, and gives code for function that prints out info or takes an integer value and returns the square of that value. More...
DSN stands for 'Data Source Name'. It is an easy way to assign useful and easily rememberable names to data sources which may not be limited to databases alone. DSN-less connections don't require creation of system level DSNs for connecting to databases and provide an alternative to DSNs. This tutorial will show you how to connect to an Access database with a DSN and without a DSN. More...
The Response object is used to send output to the client from the web server. In this tutorial the syntax, collections, properties and methods of the ASP Response object are described. More...
Single table queries are useful but they do not exploit the full power of the SQL language. SQL is relational database query language and as such, one of its most important features is its ability to retrieve information from several different related tables. In relational database terms, this process is called a join. More...
Sometimes it is necessary to set the focus to the first available form control. The problem is that complex web pages can contain multiple forms and each form individually can contain hidden or disabled elements and controls that cannot accept focus. In this tutorial we will create a function which iterates through all forms until it finds the first available form control.
More...
It's not difficult to install and run ASP on your own computer. To do that, you must install Microsoft's Personal Web Server (PWS) or Internet Information Services (IIS). More...
The Request object retrieves the values that the client browser passed to the server during an HTTP request. It is used to get information from the user. Using this object, you can dynamically create web pages and perform various server-side actions based on input from the user. In this tutorial the syntax, collections, properties and methods of the ASP Request object are described. More...
The FileSystemObject object provides access to the file system on the web server, allowing us to manipulate text files, folders and drives from within our code. In this tutorial the properties and methods of the FileSystemObject object are described. More...
Declaring variables in ASP is simple. You don't have to declare if your variable is an integer, string, or object. You just declare it, and it has the potential to be anything. To declare a variable in ASP/VBScript we use the Dim statement. If you wanted to print out the variables, you could use the ASP Response.Write command.
Learn more about the rules for declaring and naming variables in ASP/VBScript and use of Option Explicit statement in our article Variables in ASP. More...
A cookie is a message given to a Web browser by a Web server. The main purpose of cookies is to identify users and possibly prepare customized Web pages for them. This article explains benefits of using cookies and shows how to create and retrieve them. Dictionary cookies are also explained. More...
The Dictionary object is used to store name/value pairs (referred to as the key and item respectively). The Dictionary object is like an associative array, but with its own built-in functionality that looks after the basic tasks of storing and manipulating the data, and sizing for the required number of elements. More...
The Session object stores information needed for a particular user's session on the web server. It is automatically created every time when an ASP page from the web site or web application is requested by a user who does not already have a session, and it remains available until the session expires. In this tutorial the syntax, collections, properties, methods and events of the ASP Session object are described. More...
Constants just as variables are used to store information. The main difference between constants and variables is that constant value can not be changed in the process of running program. It can be mathematic constants, passwords, paths to files, etc. More...
One of the most common uses of the meta tag is to reload the web page. This is great for displaying real-time data, or as real as the refresh rate. It is very convenient to use it if you have a dynamic content on your page (for example a weather map). This tag is easy to use and misuse. More...
Just as any application, MS Access has specifications and limitations that should be remembered. The following tables specify the maximum sizes and numbers of various objects defined in Microsoft Access databases. More...
In Access, the Day function returns an integer between 1 and 31, inclusive, that represents the day of the month corresponding to the date provided as an argument. More...
The Server object provides access to properties and methods on the server. Much of functionality it provides is simply functionality the web server itself uses in the normal processing of client requests and server responses. In this tutorial the syntax, properties and methods of the ASP Server object are described. More...
DSN stands for 'Data Source Name'. It is an easy way to assign useful and easily rememberable names to data sources which may not be limited to databases alone. In this tutorial we will show you how to connect with a DSN to an Access database called 'examples.mdb' and retrieve all the records from the table. More...
Targeting windows allows the document writer to assign names to specific windows, and target certain documents to always appear in the window bearing the matching name. Targeting controls where the new document will be displayed when the user follows a link. Most of the time, clicking on a link simply loads a new document in the same window where the link was. In this tutorial we will show you how to deliver the content you want in a new window, or if you are using frames, in another frame. More...
ASP stands for Active Server Pages. It is a server side technology that enables you to make dynamic and interactive web pages that are not affected by the type of browser the web site visitor is using. More...
The Application object is used to control and manage all items that are available to all users of an Active Server application. The Application items can be variables needed for all users in the application, or they can be instantiated objects that provide special server-side functionality. In this tutorial the syntax, collections, methods and events of the ASP Application object are described. More...
Rich Text Format (often abbreviated as RTF), to surprise of many, is quite complex text data format. During its long history RTF bought a lot of add-ons that disturb the process of getting "clean" text. Let's try to solve that... More...
Constants just as variables are used to store information. The main difference between constants and variables is that constant value can not be changed in the process of running program. If we attempt to re-assign the value of the constant we'll get a run time error. More...
In Access, the Weekday function returns an integer between 1 (Sunday) and 7 (Saturday) that represents the day of the week corresponding to the date and the first day of the week provided as arguments. More...
This tutorial explains the basics of ASP. It demonstrates how to declare the variables, to do a comment, to output the results and display in a web page time and date on the web server. More...
In this article we will resolve the task of reading the "clean" text from the Office Open XML (more known as DOCX) and OpenDocument Format ODT using PHP. Note that we are not going to apply any third-party software. More...
In Access, the Rnd function returns a single containing a random number. You can specify the random number to be a value between 2 user-specified numbers. More...
The TextStream object provides sequential access to the contents of text files. This allows you to read, write, or append characters or lines to a text file. In this tutorial the properties and methods of the TextStream object are described. More...
In this article we describe how to implement record locking in web applications. Because of the stateless nature of HTTP, you cannot really know whether the user left the page or is still looking at your site. We used the lock confirmation technique combined with lock expiration to solve this problem. More...
JavaScript is a simple to comprehend and easy to use scripting language. When used in conjunction with a Web browser's Document Object Model (DOM), it can produce powerful dynamic HTML browser-based applications. In this tutorial we will print the text in a web page as well as the time and date on your computer. More...
In Access, the WeekdayName function returns the name of the day of the week corresponding to the date and the first day of the week provided as arguments. More...
The File object represents a specified file on the local machine or on a network share. To work with the File object's properties and methods, you need to create an instance of the FileSystemObject object first and then instantiate the File object through the GetFile method. Also you can get a File object reference from the Folder object, by using the Files Collection. More...
The folder object represents a specified file folder on the current machine. We can use the properties and methods of the Folder object to traverse directories on the drive, and to get at all the properties of this or any other folder. To work with the Folder object's properties and methods, you need to create an instance of the FileSystemObject object first and then instantiate the Folder object through the GetFolder method. Also you can get a Folder object reference from the Drive object, by using the RootFolder property. More...
JavaScript is a cross-platform, object-oriented scripting language invented in web browsers to make web pages more dynamic and give feedback to your user. Adding JavaScript to your HTML code allows you to change completely the document appearance, from changing text, to changing colors, or changing the options available in a drop-down list, or switching one image with another when you roll your mouse over it and much more. More...
Many times your design may have not accounted for everything it should have. Also, requirements for applications and databases in particular are always subject to change. The ALTER TABLE statement allows to change the structure of a table after it has been created. More...
In Access, the Hour function returns a number between 0 and 23, inclusive, that represents the hour of the day corresponding to the time provided as an argument. More...
In Access, the Log function returns the natural logarithm of a number. The natural logarithm is the logarithm to the base e. The constant e is approximately 2.718282. More...
The ASPError object is a new in ASP 3.0, and is available in IIS5 and later. It provides a range of detailed information about the last error that occurred in script in an ASP page. The ASPError object is only available through the GetLastError method of the Server object. In this tutorial the syntax and properties of the ASPError object are described. More...
The Drive object represents a physical drive. This drive can exist on your machine, or it can be a drive shared by another machine. To work with the Drive object's properties, you need to create an instance of the FileSystemObject object first and then instantiate the Drive object through the GetDrive method or the Drives property of the FileSystemObject object. More...
All of sudden SQL Server Management studio gives me the following error message when I'm trying to browse for the backup file location: "Property BackupDirectory is not available for Settings 'Microsoft.SqlServer.Management.Smo.Settings'.
This property may not exist for this object, or may not be retrievable due to insufficient access
rights. (Microsoft.SqlServer.Smo)" More...
After upgrading MySQL from version 5.0 to 5.5 I started getting the following message trying to edit table structure in Navicat: "Cannot load from mysql.proc. The table is probably corrupted". Luckily there is an easy fix. More...