James Northard
  • Home
  • About
  • Portfolio
  • Contact
  • Blog
September 4, 2012
James Northard
James Northard In Code, Hack

Delete a file in a directory using PHP

This code will list all of the files within a directory and give the user the option to delete the file.

Continue Reading
August 31, 2012
James Northard
James Northard In Code, Hack

List all files in a directory with PHP

This code will display all of the files within a specified directory with a filetype restriction.

Continue Reading
May 15, 2012
James Northard
James Northard In Code, Hack

Troubleshooting PHP Warning: Cannot modify header information – headers already sent

Add the following code to the top of your page: And add this code to the bottom of your page:

Continue Reading
April 30, 2012
James Northard
James Northard In Code, Hack

How to Query a Database or String for Specific Word(s)

Query from database Query from string

Continue Reading
February 22, 2012
James Northard
James Northard In Code, Hack

Export MySQL to Excel Using PHP

The code below will export every column name and value from your database into an excel document. Note: Delete the line spaces if you receive a parse error.

Continue Reading
October 20, 2011
James Northard
James Northard In Hack

Find and Replace in SQL

This is a very useful code for making edits on the fly, especially if you have extra spacing or quotes after importing values into your database. UPDATE tablename SET tablefield…

Continue Reading
October 17, 2011
James Northard
James Northard In Code, Hack

Block IP Range using Wildcard with PHP

// array’s of banned IP addresses $bannedIP = array(“^10.999.00.*”, “^99.88.77.*”, “192.168.0.1”, “^66.77.*.*”); if(in_array($_SERVER[‘REMOTE_ADDR’],$bannedIP)) { // this is for exact matches of IP address in array header(“Location: http://www.domain.com”); exit(); } else…

Continue Reading
October 17, 2011
James Northard
James Northard In Hack

Obtain a Users IP Address with PHP

if ( isset($_SERVER[“REMOTE_ADDR”]) ) { $userip = $_SERVER[“REMOTE_ADDR”]; } else if ( isset($_SERVER[“HTTP_X_FORWARDED_FOR!”]) ) { $userip = $_SERVER[“HTTP_X_FORWARDED_FOR”]; } else if ( isset($_SERVER[“HTTP_CLIENT_IP”]) ) { $userip = $_SERVER[“HTTP_CLIENT_IP”]; } echo…

Continue Reading
September 27, 2011
James Northard
James Northard In Hack

Update Checkbox Value Using PHP & MySQL

This code will send exactly two query’s to update a INT (0 or 1) checkbox field in a MySQL database. The IN operational statement let’s you match on a list…

Continue Reading
September 23, 2011
James Northard
James Northard In Hack

Redirect No Host to WWW Host

Here is the code required to redirect no host to a www host. PHP and ASP versions of the code are included. PHP ASP

Continue Reading
« Previous

Recent Posts

  • WordPress Permissions for Mac OS X Local Environment
  • Duplicate account in WHM using SSH
  • Outlook Changing Visited Link Color in Email
  • Authorize.net SIM Payment Form for WordPress
  • Convert database rows to columns using PHP

Get In Touch

Interested in working with me?

Get In Touch

© 2023 James Northard.

  • Home
  • About
  • Portfolio
  • Contact
  • Blog