Skip to main content

Handy Functions

Find Referring Domain
Find Referring Domain
Sometimes you need to get the domain name from the page referring to your page... You don't need the whole url/path/page, just the domain... You also don't need/want to worry about the 'www.' at the beginning, that's if of course it's there.... just the domain name... $justDomain = str_replace('...
Flatten and Fatten
Flatten and Fatten
A simple function that just helps if you're processing some user generated input and the user seems to have problems using uppercase letters... like for their name, etc.... # # Quick function to first switch all words to lowercase, # then capitalise the first letter of each word. # function...
Creating Config Settings as Arrays
Creating Config Settings as Arrays
Setting values in a config file is a great way to store data in one place, that can be accessed by lots of other pages... and a great way to change things quickly when a site goes live. However, sometimes you want to store several things that are similar, so an array would be a good idea... This is...
Replace \r\n with <br />
Replace \r\n with <br />
You wouldn't think was so hard, but I often come across this when processing textarea input in a contact form, into the email to the client.... A long story cut short... the solution I found was below: $msg = '<p>Address: <br />'.str_ireplace(array("\r\n",'\r\n'),'<br />', $...
Convert Database Date to Something More 'User Friendly'
Convert Database Date to Something More 'User Friendly'
// // Convert database date to something more user friendly // function userFriendlyDbDate($date){ $time = strtotime($date); return date('d/m/Y H:i', $time); }... and the other way round, so converts to database date format... // // Convert date to database date format // function...
PHP Email Validation
PHP Email Validation
Email validation is something that is needed in a variety of situations, but I’ve always struggled to find a good one…. Well, here are 2! The first is something I found online somewhere, and has been modified a little… $email = 'you@youremailaddress.com'; if(preg_match("/^[_a-z0-9-]+(\.[_a-z0-9...
PHP Logout
PHP Logout
A good logout script is needed in most applications, and here’s the one I use. I have this script in a ‘config’ file that I call at the beginning of every file in the site, so you can logout from any page… if(isset($_GET['logout'])){ // trigger if ?logout is in the url $_SESSION = array(); if(...
Another escape data function
Another escape data function
As the title says // create a function called for escaping data function escape_data($data){ $data = ereg_replace("[^A-Za-z0-9]", "",$data); $data = str_replace('\\','',$data); $data = strtolower($data); $data = mysql_escape_string(trim($data)); return $data; }
jQuery Date Picker to MySQL Database Format
jQuery Date Picker to MySQL Database Format
// //   Convert a date from jQuery 'Date picker' date to the database date format // function dpDateToDbDate($date){ $time = strtotime($date); return date('Y-m-d', $time); }
Convert Text to 'Safe Url'
Convert Text to 'Safe Url'
// // Convert Text to 'Safe Url' // // Mark Jacksons Function function safeURL($txt,$allowSpace=false,$allowCaps=false) { $find = array('/à|á|â|ã|ä|å/', '/ç/', '/è|é|ê|ë/', '/ì|í|î|ï/', '/ñ/', '/ð|ó|ò|ô|õ|ö|ø/', '/ù|ú|û|ü/', '/ý|ÿ/'); $replace = array('a', 'c', 'e', 'i', 'n', 'o', 'u', 'y...

Pages

  • 1
  • 2
  • next ›
  • last »
 
 
Jon Moore

Search form

Jon Moore

Tips 'n' Snips

 
  • Home
  • General
  • Drupal
    • Drupal 6
    • Drupal 7
    • Module Building
  • HTML & CSS
  • Javascript
  • jQuery
  • PHP
    • CodeIgniter
    • Handy Functions
    • MySQL
  • WordPress
  • About

BBC Technology News

  • General election 2019: Reddit says UK-US trade talks document leak 'linked to Russia'
  • 'How smart home tech helps me live independently'
  • NHS e-health systems 'risk patient safety'
  • General election 2019: Labour pledges to electrify UK bus fleet
  • Sweden's Ericsson to pay over $1bn to settle US corruption probe
More

Sitepoint

  • The Real Future of Remote Work is Asynchronous
  • 7 Ways Developers Can Contribute to Climate Action
  • How to Divert Traffic Using IP2Location in a Next.js Website
  • 10 Zsh Tips & Tricks: Configuration, Customization & Usage
  • Building a Habit Tracker with Prisma, Chakra UI, and React
More

Heart Internet

  • Sponsor Neil Hunter’s amazing Antarctic expedition – for Diabetes UK
  • 15 web design books of 2019 that you should read
  • 12 podcasts for every creative person’s commute
  • Ten TED Talks every designer and web creative should watch before 2019 is over
  • The rise of the robots: Will AI take over graphic design?
More
 

Backend Coders

  • PHP
  • Handy PHP Functions
  • PHP MySQL

Frontend Coders

  • HTML & CSS
  • jQuery
  • Javascript

CMS/CMF Systems

  • Drupal
  • Drupal 6 Specific
  • Drupal 7 Specific
  • Drupal Module Building
  • WordPress

About

  • Home
  • About
 

© Jon Moore 2019

All stock images are from www.istockphoto.com