This is a rundown of my top 10 PHP functions and techniques that I use on a daily basis (pretty-much) and thought I’d share them with you. Hopefully there’s some gems in there that you have never heard of (or used), that will change the way you code.
This tutorial will show you how to create an AJAX form with PHP and jQuery. The AJAX form doesn’t look any different to an ordinary HTML form, with the exception of making sure that when we submit the form, it calls a javascript function rather than pushes the user to a page (causing a new page reload). I’ll also demonstrate how we can use ‘loading’ animation for the AJAX form, [...]
This PHP login script / tutorial will show you how you can have users register on your site, and log in to access secure areas. I have seen a few tutorials around the web which show how this can be done, but they all seem to lack in security. This user membership tutorial will show a better way of having users authenticated once logged in by using their session ID.
I was working on a project today, and I needed to convert a PHP based multidimensional array into a Javascript array, so that I could use it for a dynamic select dropdown (depending on the top level category chosen, the next level select dropdown would be populated with the child elements of the top level category options – if you follow me!). Anyway, I soon realised that converting the PHP [...]
So just what are class constructors, and how can they be used within PHP classes / OOP programming? When a PHP class is first called, the class will automatically run the class constructor function, which can help automatically configure the class. This can be useful if you need to preset some instance variables, sessions or cookies – prior to using the class methods.
Please make sure you’ve followed my first PHP Class Tutorial before starting this one, as it follows on using the previous example. This tutorial will explain what $this-> is all about, and how to further your PHP class knowledge!
That’s right! I have a simple MySQL class file that you can use in your PHP projects. I’ve been using it for years, and it’s never let me down! You can grab it on my Github: http://github.com/a1phanumeric/PHP-MySQL-Class.
It’s relatively easy to make URL safe strings for use by mod_rewrite. Let’s use the example that you have a form that adds a new blog post to your site. When the user submits this form, you want to generate a URL safe string (based on the title of the blog post) for mod_rewrite to use. This little snippet will show you how this can be achieved in one line [...]
This is a simple to use script that can be called at anytime to insert a date picker into your form. Example Your browser does not support IFRAMES. Please view the date picker at http://edrackham.com/tutorials/php-date-picker/
UPDATE: Please see my newer atricle on how to retrieve a random row, faster, without RAND(). This post assumes you know how to create and use a connection to a MySQL database in PHP and have a table named ‘quotes’ as shown below. In this post, I will aim to teach you how to use PHP to pull random quotes from a MYSQL table of quotes. This can be easily [...]