Image for post
Image for post

My latest mini-side project is a Chrome Extension that adds two additional methods to search: one via the search bar and one in the right click menu.

Similar to my “Search Funnel” Chrome Extension (also an app for Android and iOS), this saves you the step of visiting the website prior to searching.

Enhanced Search Bar (Feature 1 of 2)

This targets those who prefer keyboard shortcuts and minimize mouse usage.

Pro Tip: the keyboard shortcut to go to the search bar is Ctrl + L (Windows) or Command + L (Mac)

In the search bar, simply type two periods (“..”) and then hit space.

Image for post
Image for post

Enter what you want to search. Then use your arrow keys (or the mouse) to select where you want to search. …

Image for post
Image for post

I previously wrote a tutorial on creating a simple PHP Contact form; this is Part 2 of 2 where I go over some more advanced techniques.

Issue: Who is the email from?

So far we can send an email, but it comes “from” whatever the default configuration was set up as. By this, I mean that the e-mail may come from While this is functional, we can change who the email comes “from”. This serves two purposes:

  1. Less of a chance it will end up in spam/junk
  2. It’s more professional if you use this code to email your users (and not just yourself)

The PHP mail() function accepts an optional parameter called “headers”. Use this code, of course changing the appropriate content for your…

Image for post
Image for post

This is a basic tutorial will show you how to create a Contact Form for your website that will send you an email. This is commonly used to collect feedback from users without them having to open their email client manually to send you an email. In this example, we’ll be coding in PHP.

Note: if you’re looking for a WordPress solution, I instead recommend using the plugin “Contact Form 7”. My tutorial is for those who want to type PHP code.

We need two web pages:

  1. The page where a user can enter data in (ex. …

Image for post
Image for post
Screen recording above is in slow motion to demonstrate the concept

Using a sequence of keyboard shortcuts to copy a formula across multiple rows/columns in Excel- instead of a mouse- is the greatest time saver I have.

My most common use-case is when I have a formula at the top right of my data that I need to paste it downwards, filling all cells in the right-most column. While this can be done with the mouse, I find it faster to use keyboard shortcuts.

In this example, I will assume the formula in Cell C2 needs to be copied down to through Cell C7:

Image for post
Image for post

The first step is to put in the formula in the top-right most cell (here, Cell C2). …

You can get the last cell in Excel using the following line of VBA code:


However if your dataset was modified (specifically, if you deleted rows), then doing that won’t get the right value. It’ll return what the value was before the data was modified.

Instead, I use the script below.

Get the Count of Rows

I often need to loop through the entire dataset. I first select Cell A1, and then I continue down to the next row until there’s a blank. …

Image for post
Image for post

When I was first starting to write PHP, most tutorials I found placed the HTML output inside of the PHP. It’ll have an entire block of code that is only PHP, and it prints out HTML (and CSS and JavaScript for that matter).

There’s a better way though.

Take a look at lines 1 to 15 below. It does the same as lines 20–32:

The second section is easier to read (and write!).

A web server ultimately evaluates all of the code and prints out HTML. It doesn’t matter if you write the HTML in, or out, of the <?php … ?>

A best practice in how to organize your PHP files.

Image for post
Image for post
Final output of what we’ll be making

A friend of mine needed a PHP template, where he can easily modularize different parts of this site. By this, I mean he’d have a separate file for the “navigation” and he can just include that file in his code where he wants it to appear. Same thing for the “footer” and other aspects of the site.

As mentioned in my book on PHP, there are two common methods I use:

- “including” files where needed

- creating a PHP function, and calling that as needed

My book goes through the second (“function”) approach, however for this example of a simple site, I thought the first (“include”) approach would be better. …

A quick tip I’ll be using on my future web applications: store the User ID as a constant.

When you have users who log in to your site, you’ll most likely give each one a unique “User ID” — probably in a Session variable. One of the first things I do with my code is to set this session variable value in a PHP constant. It’s not sufficient to store it in a “local” variable for many of my purposes.

I use a lot of PHP functions, and I’d rather not have to pass this in as a parameter. Due to variable scope limitations, you can’t reference a local variable, but you can reference a constant within a function. …

I was originally going to use eregi() — which is not only deprecated, but removed in PHP 7.

Instead I’m using:

function isValidateEmail($EmailToCheck) {  if (strlen($EmailToCheck) == 0) return false;if (preg_match("/^[\+a-zA-Z0–9._-]+@[a-zA-Z0–9._-]+\.([a-zA-Z]{2,4})$/", $EmailToCheck))
return true;
return false;

Originally I just replaced eregi() with preg_match() but got an error. I had to change the pattern by adding “/” before and after.

I’m making a calendar to show availability. My calendar is “daily,” so I can only show ONE day at a time.

This presents a problem in that if someone is available from 10PM — 2AM. When looping through the times, starting at 10PM, I’ll never reach 2AM (since, as I increment from some block of time starting at 10PM, it’ll stop at 11:59 PM — again, I’m only showing one day).

In this example, the ideal solution was to show:

  • 12AM — 2AM — available
  • 2AM — 10PM NOT available
  • 10PM — 11:59 PM available

To implement, I reversed the open/closed time (available from 2AM — 10PM), but I blocked out all of these times. This gives the sample above. I was displaying 24-hour times, but couldn’t convert it correctly. I tried various date() and strtotime() functions, but I couldn’t add or loop through times correctly. …


Steve Sohcot

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store