Easily Create External Links Without the Target Attribute
Today's tip is extremely short and simple, and to a lot of folks may be a
"Duh!" sort of tip, but I felt it was worth sharing.
I'm a big fan of keeping sites valid in XHTML 1.0 Strict.
When I first started paying attention to standards, one of the things that
stumped me right off the bat was the use of external links.
The Problem with target="_blank"
As I'm sure most people know, the use of the target attribute isn't
considered valid. However, in order to open links in a new page,
the only tool provided by HTML is the target attribute!
I had been creating external links for as long as I could remember using
the following format:
<a href="http://example.com" target="_blank">External link</a>
The Fix: rel="external"
The HTML
When...
read more
Show the Most Popular Categories with PHP
This week, we'll be going over a quick way to determine what the most
popular tags are in a series of tagged entries.
Files and Data Required for This Exercise
Files
For this exercise, we'll be using a comma-delimited string (i.e. "tag 1, tag 2, tag 3, etc.") as a set, and we'll assume that there are multiple entries, each with a set of tags generated by the user.
Pretty much every blog, bookmarking resource, and app these days features tagging in some capacity. Tags help users quickly identify what an... read more
Improving the Simple Contact Form
A few weeks back, we learned how to build a simple
contact form to allow our users to send us feedback directly from a
site.
As noted in the comments, there were a few shortcomings with the contact
form. Most notably, there was no spam protection whatsoever. Additionally,
if the user made a mistake, their message would be lost, which is
extremely inconvenient.
To make this contact form ready to use on a real website, we'll be adding
both a basic spam protection system and the ability to store the message
in a session in case the user makes a mistake.
NOTE: Like all projects built on this blog, this is being
presented as a teaching exercise and a demonstration, so be sure to
double-check it before...
read more
Send HTML and Plain Text Versions of Email
Recently, I've been dealing with sending email from applications an awful
lot. At first glance, sending a basic message from PHP is easy:
<?php
mail('test@example.com', 'Subject Line', 'A message!');
?>
Sending complex messages with HTML formatting and/or attachments, however,
can be tricky. Today, we're going to cover sending HTML email to a user
while still including a plain text version for email clients that don't
support HTML.
See the Demo | Download the Source
Part One: Understanding Email Structure
Basic email structure is something like this:
To: someone@example.com
Subject: Test Email
From: Test <testing@example.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="==PHP-alt_xd50dc5b6ee7a015fb67e36ba692a93ad961d5f7dx"
X-Nonspam: None
--==PHP-alt_xd50dc5b6ee7a015fb67e36ba692a93ad961d5f7dx
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
This Is a Plain Text Email
This message has no HTML. http://w3schools.com
--==PHP-alt_xd50dc5b6ee7a015fb67e36ba692a93ad961d5f7dx
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<body>
<h1>This Is an HTML Email</h1>
<p>
This message is composed in <a
href="http://w3schools.com">HTML</a>.
</p>
</body>
</html>
--==PHP-alt_xd50dc5b6ee7a015fb67e36ba692a93ad961d5f7dx--
This looks a little daunting at first, but if we take...
read more
- «
-
-
- »