How to Capture User Input from Command-line PHP

By Josh Sherman
1 min read
development
php
cli

When using command-line PHP capturing input is a bit different than when building a web application. Instead of building a form and interrogating some variables, you have to actually prompt the user for the input and then analyze it to determine if what the user input was what you were […]

The Importance of a Logout Page

By Josh Sherman
2 min read
development
advertising

Running social networks have proven eye opening in regard to how users interact with a website. One thing that I’ve noticed that I didn’t necessarily expect is that quite a few people click the logout button. Perhaps it’s because they have more than one account (tsk tsk as we don’t […]

How to Generate a Random Number with PHP

By Josh Sherman
1 min read
development
php

Generating a random number in PHP is very simple and like most things, can be done a number of different ways. The old standby is to use the function rand() to to generate a random integer between the minimum and maximum values that you provide. To generate a number between […]

Using Transactions with PHP Data Objects (PDO)

By Josh Sherman
1 min read
development
php
database

With PHP Data Objects, transactions are pretty simple. To be able to use a transaction, you simply wrap your queries with a call to beginTransaction() and either use commit() or rollBack() at the end. Rolling back is at your discretion but the easiest implementation would be to wrap the queries […]

How to Use Prepared Statements in PHP

By Josh Sherman
3 min read
development
php
database
security

Now that we know how to create a connection to our database using PHP Data Objects, let’s talk a bit about prepared statements. Now I’d like to think that we’ve all made this mistake before, taken user input and used it in an SQL query something like this: $db->execute('SELECT * […]