Close

php

3 Ways to Verify an Email Address Using HTML, jQuery and PHP

When you verify an email address, there’s really three things you want to do:

  1. Don’t submit the form unless the email address is valid
  2. Give hints about what’s wrong and how to fix it
  3. Make sure malicious data doesn’t get into your database

Well, here’s a handy little snippet that does all three using HTML, jQuery and PHP. Feel free to use this how you need in your projects. And, if you want it you can get the source code as a supporting listener on Patreon.

Anyway, here’s the video… see what you think:

And, if you’d give ol’ JMO a like I’d appreciate it!

And like I said the source code is available on Patreon for the ever-awesome folks who support the show. (Hint: Be awesome. Join them.)

P.S. If you liked the show, give it a like and share with the communities and people you think will benefit. And, you can always find all my tutorials, podcast episodes and more on johnmorrisonline.com, @jpmorris on Twitter and youtube.com/johnmorrisvideo.

Subscribe to the Podcast

[saf]

May 4, 2016

How to Get the First Value In An Array Using PHP When You Don’t Know the Keys

Arrays are like that crazy uncle who gets a little too drunk at Christmas and starts telling inappropriate jokes at the dinner table.

You love ’em… but you hate ’em.

You can efficiently store and grab tera-tons of data with them… but when you just want to get the value of the 2nd element in the 3rd dimension of one… you feel like you gotta break out the code-jitsu to get at it.

Have no fear! Captain JMO is here!

I just cranked out a new video for you showing you several different ways to get at different keys and values in an array.

Technically, I made it to get at the FIRST value in an array WHEN you don’t know what the keys will be. But, you can use these functions and fancy combinations thereof to get a whole slew of data in your arrays.

Plus, I slipped in a little advice on why seeing the several different methods I used is important even if you already know how to do this.

Hint: I squash those know-it-all developers egos like annoying little mosquitos.

Anyway, here’s the link… judge for yourself:

And, if you’d give ol’ JMO a like I’d appreciate it!

Oh and the source code is available on Patreon for the ever-awesome folks who support the show. (Hint: Be awesome. Join them.)

P.S. If you liked the show, give it a like and share with the communities and people you think will benefit. And, you can always find all my tutorials, podcast episodes and more on johnmorrisonline.com, @jpmorris on Twitter and youtube.com/johnmorrisvideo.

Subscribe to the Podcast

[saf]

April 27, 2016

How to Create a Contact Form Using PHP

When you create a contact form in PHP, there’s a couple key parts you need to make sure are in place so the person actually using the form doesn’t want to suddenly get into knife-throwing (at your head) afterward.

You need validation that make sense and is easy to understand.

I prefer the kind that shows up all at the top of the form, because when you have a long form and missed one checkbox and have to go hunting through the form like you’re looking for a lost sock… knife-throwing becomes a viable option.

Next, you need to make sure when there is an error, you don’t lose all the data you entered already.

Nothing will get knives, bricks, cars, kitchen sinks, those big bats with spikes on them… thrown at your head faster than making me re-enter all the form field data again because I forgot to check whether I like chocolate bunnies or not.

With all that in mind, I humbly present to you MY contact form tutorial:

It’s possible this could be YOUR contact form… meaning you’re obviously cool like me and think the way it’s built is perfect.

Or, you may to prefer to hurl insults at me on YouTube about it.

Either way, there’s 100 ways to skin a cat (but why would you)… and this is just one. Use it if you like it.

P.S. Ah yes! That pesky source code. You can get that as a supporting listener of the podcast. Learn how to do that here: http://www.JohnMorrisOnline.com/patreon

P.P.S. If you liked the show, give it a like and share with the communities and people you think will benefit. And, you can always find all my tutorials, podcast episodes and more on johnmorrisonline.com, @jpmorris on Twitter and youtube.com/johnmorrisvideo.

Subscribe to the Podcast

[saf]

April 20, 2016

JMS056: Send Form Data Via Email, 2016 Web Design Trends, The Risk-Takers Mindset and More

In this episode of the John Morris Show I share the Web Design trends to watch in 2016, how to send form data via email, the risk-takers mindset and how to capitalize in a competitive industry and more.

Subscribe to the Podcast

[saf]

Here’s the line-up:

  • Before You Write Your New Years Resolutions [00:48]
  • Web Design Trends to Watch in 2016[13:57]
  • Risk-Takers Mindset and Capitalizing In a Competitive Industry [26:58]
  • How to Send Form Data Via Email [31:30]
  • 4 Trends That Will Disrupt the Way We Work by 2021 [40:54]
  • Weekly WebDev Q&A [52:00]

Links mentioned in this episode:

If you liked the show, give it a like and share with the communities and people you think will benefit.

Finally, you can always find all my tutorials, podcast episodes and more on johnmorrisonline.com, @jpmorris on Twitter and youtube.com/johnmorrisvideo.

December 30, 2015

JMS055: 6 Common PHP Security Issues and Their Fixes And More

In this episode of the John Morris Show I share what web designers can learn from the Miss Universe gaffe, 6 common PHP security issues and their fixes, is it worth trying Upwork, answers to your questions and more:

Subscribe to the Podcast

[saf]

Here’s the line-up:

  • Why Web Development in 2015 Is Different [00:44]
  • What Web Designers Can Learn From Miss Universe [9:58]
  • A Winning Mindset For Web Developers [19:31]
  • 6 Common PHP Security Issues and Their Fixes [25:20]
  • Is It Really Worth Trying Upwork? [33:03]
  • Weekly WebDev Q&A [40:14]

Links mentioned in this episode:

If you liked the show, give it a like and share with the communities and people you think will benefit.

Finally, you can always find all my tutorials, podcast episodes and more on johnmorrisonline.com, @jpmorris on Twitter and youtube.com/johnmorrisvideo.

December 22, 2015

How to Use the PHP DateTime Class Instead of the PHP Date Function

In this PHP tutorial, you learn how to use the PHP DateTime class introduced in PHP 5.2 instead of the PHP date function. Watch the tutorial below:


Links mentioned in the video:

Get the source code for this video as a supporting listener of the John Morris Show on Patreon

If you get value from this code snippet, please consider sharing it with another developer or group who could benefit from it.

November 19, 2015

How to Create a Custom Error 404 Not Found Page

In this PHP tutorial, you’ll learn how to create a custom 404 page not found error page. Watch the tutorial below:

Links mentioned in the video:

Get the source code for this video as a supporting listener of the John Morris Show on Patreon

If you get value from this code snippet, please consider sharing it with another developer or group who could benefit from it.

November 5, 2015

[Periscope] What WordPress Development Tutorial Should I Invest In?

In this week’s WebDev Q&A, I answer questions on:

  • What WordPress development tutorial you should invest in?
  • The key to continually getting freelance clients
  • Sending emails with PHP’s built-in mail() function

Watch below:

Links mentioned in the video:

If you get value from this video, please consider sharing it with another developer or group who could benefit from it.

November 3, 2015

How to Send Mail Using PHP

In this PHP tutorial, you’ll learn how to send mail using PHP. Watch the tutorial below:

Links mentioned in the video:

Get the source code for this video as a supporting listener of the John Morris Show on Patreon

If you get value from this code snippet, please consider sharing it with another developer or group who could benefit from it.

October 29, 2015

[Periscope] How to Search a Forum With MySQL and PHP

In this week’s WebDev Q&A, I answer questions on:

  • Is it a good idea to self teach myself and still pursue a career in web development?
  • Which front-end framework should I start with?
  • How do I create a good search for my forum with PHP and MySQL?
  • I don’t know where to start with web development!
  • I want to learn how to get new clients,

Watch below:

Links mentioned in the video:

If you get value from this video, please consider sharing it with another developer or group who could benefit from it.

October 27, 2015

How to Parse XML With SimpleXML and PHP

In this PHP tutorial, you’ll learn how to parse XML using SimpleXML and PHP.

Watch the tutorial below:

Links mentioned in the video:

Get the source code for this video as a supporting listener of the John Morris Show on Patreon

If you get value from this code snippet, please consider sharing it with another developer or group who could benefit from it.

October 22, 2015

[Periscope] How to Learn Object-Oriented Programming in PHP

In this week’s WebDev Q&A, I answer questions on:

  • There is so much to learn and it’s changing all the time, how do I know where to focus and what to choose to pursue?
  • How do I learn object-oriented programming?
  • How can one tell if I am good enough?
  • I’ve learned HTML and CSS, how do I make the transition into learn PHP, MySQL and Javascript?
  • I’m learning how to work with databases, what all do I need to learn?

Watch below:

Links mentioned in the video:

 

If you get value from this video, please consider sharing it with another developer or group who could benefit from it.

October 21, 2015

How to Create a Zebra Striped Table With Odd Even Row Colors Using PHP

In this PHP tutorial, you’ll learn how to create a zebra striped table by adding odd and even classes in a loop using PHP.

Watch the tutorial below:

Links mentioned in the video:

Here’s the code I used in the video:

Get the source code for this video as a supporting listener of The John Morris Show on Patreon

If you get value from this code snippet, please consider sharing it with another developer or group who could benefit from it.

October 14, 2015

How to Position Yourself to Get More Freelance Jobs

[soundcloud url=”https://api.soundcloud.com/tracks/161948278″ params=”color=2eaef0&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false” width=”100%” height=”166″ iframe=”true” /]

I was recently asked: “How do I fill out my profile on sites like Elance and oDesk? How do I fill them out in a way that’s honest but more impressive than leaving them blank?”

Here’s the simplest way I can put this…

Your unique situation can and SHOULD be positioned to highlight your advantages. For example, when I started looking to get hired for freelance IT jobs I was completely self-taught and I believed that was a disadvantage.

I believed coders who had gone to school were in a better position than me and would have an easier time convincing clients to hire them.

But, I quickly found out that clients were often MORE impressed with someone who was self-taught and so I began using that to my advantage.

I would highlight that I was self-taught and I learned by working on REAL projects (instead of fake scenarios in some college “lab”).

And guess what… it works!

Since then I’ve come to understand that whatever situation you’re in… you can position it to your advantage. It’s “all about how you tell the story”… and it’s your job to tell YOUR story and not worry about anyone else’s.

So, how can you tell your story in a way that is compelling… that highlights your unique skills, qualifications and experiences?

Got a Question?

Call (515) 344-3163 to ask me your most burning coding question right now?

Subscription Links

 

Photo by: Kat Ter Haar

August 6, 2014

Separation of Concerns, MVC, and How to Get Started as a Freelance Coder

Build Better Websites Using a Separation of Concerns

Easily one of the biggest mistakes new coders make… inter-mingling content, presentation, and behavior… making it a nightmare to maintain and update your code. In the first segment of this episode of the John Morris Show, I reveal how to avoid that whole mess by building your websites using a “separation of concerns”.

What is MVC? How Do I Use It?

I get this question every day. MVC has become a buzzword in the developer community and many developers have been told they need to build their applications this way… but don’t know what it is or how to do it.

In the 2nd segment of this episode, I answer those questions and show you how to start building your applications using the MVC pattern.

How Do I Start Getting Freelance Clients?
(more…)

April 22, 2014

Should I Use mysqli_real_escape_string With Prepared Statements in PHP?

Graham recently asked me:

Do I still need to used mysqli_real_escape_string when used prepared statements in PHP?

The simple answer is no.

The way it used to work is that you would take form input data, put that into a variable, and inject that data into your MySQL query in order to add that data to the database.

Now, a big problem with that is SQL Injection attacks where a hacker could inject SQL code into your query and perform actions on your database… which is something you definitely don’t want.

So, the standard solution became using mysql_real_escape_string to sanitize data before sending to the database.

Of course, that’s not the preferred solution anymore. Prepared statements are:

But, with PHP5, the PHP developers built an entire class into PHP for working MySQL. With that class, there are now prepared statements in PHP… and prepared statements allow you to “bind” data to a query using sprintf-like syntax… rather than “inject” your data into those queries.

And, with this new system, the methods that bind the data to your query do the sanitizing for you. So, mysqli_real_escape_string is no longer necessary WHEN you bind values this way.

Of course, if you have some other way you’re injecting input data into your queries, you still need to sanitize that data… and mysqli_real_escape_string is still the main method for doing that.

June 6, 2013

How to Create a Custom Loop in WordPress Using WP_Query

In this tutorial, I’ll show you how to create a custom loop in WordPress using WP_Query. Plus, I’ll explain why you want to use this instead of query_posts when creating custom loops like these.

<?php
/*** Custom Loop ***/
function demo_loop() {
$args = array(
'cat' => 3,
'posts_per_page' => 1
);

$demo_posts = new WP_Query($args);

if ( $demo_posts->have_posts() ) {
while( $demo_posts->have_posts() ) {
$demo_posts->the_post();

$output .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
}

return $output;
}

add_shortcode( 'demo_custom_loop', 'demo_loop' );

February 11, 2013

How to Create an ics Import File Using PHP

In this video, you’ll learn how to create an .ics import file using PHP. This allows you to dynamically generate the .ics file based on stored event data. Users can then download the file and import the event information in their calendar of choice… Outlook, Thunderbird(Lightning), Apple Calendar, etc.

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
/**
* Get the event ID
*/
$event_id = @$_GET['event_id'];
/**
* If no event ID or event_id is not an integer, do nothing
*/
if ( !$event_id || !is_numeric( $event_id ) ) {
die();
}
/**
* Event information
*/
//$event = get_event($event_id);
$event = array(
'event_name' => 'Test Event',
'event_description' => 'This is a test event. This is the description.',
'event_start' => time(),
'event_end' => time() + 60*60*2,
'event_venue' => array(
'venue_name' => 'Test Venue',
'venue_address' => '123 Test Drive',
'venue_address_two' => 'Suite 555',
'venue_city' => 'Some City',
'venue_state' => 'Iowa',
'venue_postal_code' => '12345'
)
);
$name = $event['event_name'];
$venue = $event['event_venue'];
$location = $venue['venue_name'] . ', ' . $venue['venue_address'] . ', ' . $venue['venue_address_two'] . ', ' . $venue['venue_city'] . ', ' . $venue['venue_state'] . ' ' . $venue['venue_postal_code'];
$start = date('Ymd', $event['event_start']+18000) . 'T' . date('His', $event['event_start']+18000) . 'Z';
$end = date('Ymd', $event['event_end']+18000) . 'T' . date('His', $event['event_end']+18000) . 'Z';
$description = $event['event_description'];
$slug = strtolower(str_replace(array(' ', "'", '.'), array('_', '', ''), $name));
header("Content-Type: text/Calendar; charset=utf-8");
header("Content-Disposition: inline; filename={$slug}.ics");
echo "BEGIN:VCALENDAR\n";
echo "VERSION:2.0\n";
echo "PRODID:-//LearnPHP.co//NONSGML {$name}//EN\n";
echo "METHOD:REQUEST\n"; // requied by Outlook
echo "BEGIN:VEVENT\n";
echo "UID:".date('Ymd').'T'.date('His')."-".rand()."-learnphp.co\n"; // required by Outlok
echo "DTSTAMP:".date('Ymd').'T'.date('His')."\n"; // required by Outlook
echo "DTSTART:{$start}\n";
echo "DTEND:{$end}\n";
echo "LOCATION:{$location}\n";
echo "SUMMARY:{$name}\n";
echo "DESCRIPTION: {$description}\n";
echo "END:VEVENT\n";
echo "END:VCALENDAR\n";

October 22, 2012