Email (contact) form class: make sending emails easier!
Tags CMS,Code,Dan,Website Development - posted by Daniel on 15 May, 2009 05:18 pm
As a PHP developer, I’m always having to create functions to send email forms to both customer and website administrator so that everyone can keep track of what’s going on. A basic example would be your standard web contact form.
Sometimes it can be a big job if I’m dealing with lots of fields, (we once had a project with over 100 fields – big form!!!) as each one needs to be built individually and maintained manually.
What I’ve done to speed up the process is written a small class which works with the most popular PHP email library – PHP Mailer. This small class will generate email form automatically according the $_POST information, and I’m gonna share it with you lucky web cats.
Step 1: Create your email template database
First we need create a table to store your email form, this table can be defined by yourself to suit the project you’re working on
Example:
1 2 3 4 5 6 7 8 | CREATE tblEmail ( code varchar(10) from_Email varchar(60), from_Name varchar(60), subject varchar(80), content Text, Primary key (Code) } |
In the content field, you can store your email template with tag you’ve defined. In my example, the tag will be formatted like this: [tagname].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <h1>My Contact Form</h1> <table> <tr> <td>Name</td> <td>[name]</td> </tr> <tr> <td>Phone</td> <td>[phone]</td> </tr> <tr> <td>Email</td> <td>[email]</td> </tr> </table> |
Step 2: Update the HTML form on your website
You don’t need change your form too much, simply update the name of each field and make sure it comes with the same name of your tag. This class works with text, select, checkbox, option and textarea.
Sample form:
1 2 3 4 5 6 | <form action=”send.php” method=”post”> <p>Enter your name: <input type=”text” name=”name”></p> <p>Enter your phone number: <input type=”text” name=”phone”></p> <p>Enter your email: <input type=”text” name=”email”></p> <input type=”submit” value=”submit”> </form> |
Step 3: Use the class to send email
Remember to download PHPMailer and include it in your script with the email form class.
The rest is simple:
1 2 3 4 5 6 | Include (“phpmailer.php”) Include (“emailform.class.php”) Form=new EmailForm(“code”); ← The key to loading up the correct email template from database Form.generate_email($_POST); Form.send(“MaxGen Media”,info@maxgen.co.nz”); |
And that’s it!! You can use this class to generate big forms that get sent out to your customer and web admin.
You can also customise the constructor
You can modify this EmailForm class to load up an email template:
1 2 3 4 5 6 7 8 9 10 11 | function __construct($id=0) { $this->id = $id; // Place your query to load your email template here. $rs=mysql_query(“select * from table where code=’$id’); row=mysql_fetch_row($rs)) // Fetch data and store email information $this->subject = $row['subject']; $this->from_name = $row[‘from_name’]; $this->from_email = $row['from_email']; $this->content = $row['content']; } |
Download the files
Enjoy. If you need a hand be sure to leave a comment.
We’ve been busy little bees
Tags CMS,Dan,General,SEO,Website Design,Website Development - posted by Court on 14 Aug, 2008 01:48 pm
Long time no see, with good reason though.
Catch up time:
Last month, both Dan and myself were fortunate enough to be invited to speak to a couple of very different groups of people.
First was a conference held by Tristan Nickless of Word by Mouth and the collective crew of Speech Pathology Australia and the New Zealand Speech-language Therapists’ Association. It was great to speak to a bunch of interested owners of private speech therapy practices about the pros (no cons here) of getting a Website.
A week or so later, we met up with the emerging talent out of Botany Downs Secondary College. First off, what a sweet complex. The school has only been around a few years and has already been labelled as the ‘learning institution of the future’, surely thanks in part to the progressive teachings of Mr. Enda McKenna (head of IT). During the hour or so we spoke we covered a few topics including working with clients, design principles, SEO and general traps for young players.
Couple of pics below:
Big thanks to both groups, was our pleasure to bore you all to tears.
Stay tuned this week and next for some updates to the blog as we:
- Unveil the big projcet that’s been keeping us from posting regularly
- Introduce a new weekly feature
- Spew miscellaneous trite
SEO – IP addresses, domain names and you
Tags Dan,SEO,Web Hosting,Website Development,XSIS - posted by Daniel on 26 Feb, 2008 08:35 am
Dan Chung goes over the significance of localised search engines in this post
Have you tried hard to get top search engine ranking by following various optimisation guides, but no matter how many keywords you place on your Website it is still deemed invisible by Google and Yahoo?
Fret not, you may have missed a key point – Your IP address and domain name. Allow me to explain:
IP Address
From a search engines point of view, if your Website is hosted in the United States for example, then there is a large possibility that the content of your Website is targeting to people who live in North America. Search engines can easily tell where your Website is hosted by checking your IP Address. So if your Website is located in the USA, then you will lose visibility for people searching for your site with www.google.co.nz.
Domain Name
Again, if your domain name is “abc.com”, search engines will always believe your website is marketed towards American visitors. As a result you may get high ranking if searched for on www.google.com, but a lower one on www.google.co.nz. To us it makes sense: if you run a New Zealand based business, then use a .co.nz domain – it’s about targeting your audience accurately. For some reason people believe the use of a “.com” domain makes their Website seem bigger – more “global” even. This isn’t the case. If anything you’re just reducing the amount of real visitors (the ones actually interested in your Website) that will find you.
What is the best option?
Using the theories above, the best scenario is to host your Website locally and use the domain extension of your country.
For example, if you are targeting New Zealand customers, then you can choose to host with a Kiwi company like ICONZ, SiteHost or MaxGen, and then also apply a “.co.nz” domain name.
However, as a general rule New Zealand based Web hosting is considerably more expensive than other countries. And as a result, a lot of Kiwi Website owners choose to host their Websites offshore; saving money but sacrificing search engine visibility.
What it comes down to is if the price is a big issue when you choose where to host your Website, then at least choose a “.nz” domain name. That way you will have greater Website visibility in localised versions of Google.
Fortunately for all XSIS WebMaster customers, we host all our Websites locally – so to always experience the best possible speed and local search engine rankings.
Saying ‘No’ to JavaScript for SEO?
Tags Dan,SEO,Standards,Website Design,Website Development - posted by Daniel on 14 Nov, 2007 05:02 pm
Today Dan explains the difference between organic links and using JavaScript to links to other pages, and its effect on Search Engine Optimisation.
JavaScript is a tool that’s widely used in the Web design industry today. Essentially it gives Web designers more power to control objects on pages and to deliver special/fancy effects and interactive functions to Website visitors.
Unfortunately when you use JavaScript to link to other pages on your Website, it will not be indexed by the Google Robot. This is because Google will not treat your link as a real link – but rather as a script, and therefore your Website will not be “fully” indexed and will lose visibility on search engines.
Should I remove JavaScript to appease the search engines?
To blatantly contradict what I just said, I’m now going to clarify that it isn’t entirely true to say Google will not read any JavaScript links.
Some JavaScript is still recognised by Google, such as “On-click” events. You can still use JavaScript, but you must make sure search engine robots accept your code.
Relating to your Website visitors
According to some Web trend analysis report I read [yeah citation needed, I can't remember though], about 3% of users have a non-JavaScript Web browser. This includes users who disable JavaScript functions from their Web browser to avoid possible hacks and virii. So if you’re using JavaScript in any form on your site you’re automatically blocking a portion of your audience.
Conclusion
To design and develop a modern Website, we have no choice but use JavaScript. However, if you’re using JavaScript to link pages, add alternative links to ensure your site is indexed by the search engines.
For example, go ahead have a fancy JavaScript drop down menu in your header, but remember to put normal text links on the footer, so that the robots still have a way to dig through your Website.
MaxGen Media
All of our Websites are fully search engine optimised, so you can expect all your Web pages to be indexed by Search Engines. As a result the visibility of your Website will be maximised and enjoyed by the world.
Don’t cheat Google!
Tags Dan,SEO,Website Development - posted by Daniel on 28 Aug, 2007 05:42 pm
Daniel Chung dives into the seedy world of bad search engine optimisation in his latest post.
There are a lot of ways to optimise your Website for search engines. Normally, we can optimise by developing simplified site structures, link population and by using correct keywords to get a better ranking on Google. However, there are some SEO/Web Design companies that utilise “cheats” (also known as “Spamdexing“) to get good rankings on Google. Over the years Google has become increasingly observant and will analise your Website to see if you’ve been cheating. In this article, I’m going to go over some SEO “don’ts”, so make sure your site isn’t involved in the following:
Invisible Text / Hidden Links
Invisible text refers to text that can be found by search engines but not Website visitors. There are a lot of different ways to make this happen, but the easiest way is make your text colour the same as background colour.
Most of search engines have ability to detect hidden text; and will treat it as cheating which will result in your site ranking being decreased or in some cases in your domain being black-listed. Some Websites may be lucky enough to not be recognised as “cheating” and can get high ranks in search results. It is very risky however and by no means do we endorse it.
Bait-&-Switch
This works by creating a fake Website that contains heaps of text and keywords which is then submitted to Google. After Google has indexed your site and has given it a (possibly) high rank, the dummy site is replaced with an official version. Because Google is already indexed your Website your rank will not be affected until the next update, which may not occur for a good 3-4 months.
Misleading Words
Some sites have a lot of popular keywords in their text, but they aren’t at all related to that actual Website. For example, the keyword “dating” on a “car dealership” Website, that when people search for “dating”, they will see a car dealer listed. It is terrible SEO behavior and Google has clever technology to block those Websites.
Repeated Words
This is also called “keyword stuffing”, which means you are trying to over-repeat your keywords to get higher search engine ranking. For example, someone can put text such as this on their homepage:
“welcome to car dealer super cheap car dealer/budget car dealer, we are a car dealer based in Auckland, as a car dealer, we do everything car dealer can do and we are best car dealer in Auckland”
It not only looks awful but has little actual effect on search engine rankings as Google et al limit the total keywords indexed from a site.
Deceptive Redirects / Doorways
Essentially this means visitors will be redirected to another page after reaching the “landing” (or home) page. The landing page is full of keywords that aren’t related to the Website. Search Spiders are now smart enough to ignore doorway pages automatically. This isn’t to be confused with a “Splash” page which acts as a legitimate lead-in to some sites.
Link Spamming
Typical link spamming activities include:
• Link Farms
• Bulk link exchange programs
• Mass cross-linking
These schemes have been devised to create a huge amount of pages that all link to each other. Therefore it is possible to develop the perception to search engines that “these Websites are popular because there are a lot of Websites that link to them”, which results in better rankings. Most search engine spiders have the ability to find these link-spamming pages. If your Website has been identified as a “link farm”, you will be penalised no matter whether you did it on purpose or not. In general though, sites flagged as link spamming have been so because they serve no purpose other that to spread the reach of other useless Websites.
There are lot of other ways to deceive Google, but the search giant is always evolving to protect itself and you against these Web cheats. To summarise, if you want your site optimised: don’t do it via the ways mentioned above. Either read my other SEO posts, or arrange a time to have a chat with one of us here at MaxGen Media. We’re are bonafide SEO professionals, and in the coming weeks I’ll be providing case studies and success stories of some of our clients to prove it.
What is PageRank?
Tags Dan,SEO,Website Development - posted by Daniel on 27 Jun, 2007 12:18 pm
Daniel Chung presents another post. This time he details the theory behind the Google Pagerank™ system.
PageRank™ (PR) is a key that makes Google the most powerful search engine in the world, and has made all its competitors fall behind. And it is very important to your Website as well.
Basically, PR is a score of trustee to a Webpage, and you can get higher PR if you get many other Webpages linking to your Website. Because PR is based on each single page, you will have multiple and differing PR across one Website.
Normally your “homepage” will get a higher PR than your other pages, because generally when other Websites want to make a link to your Website, they will choose to link to your homepage, therefore your homepage is quite important to Google.
PR is ordered from 0 to 10. A lot of famous/high traffic Websites are rewarded with high PR.
Example Websites
International sites:
- CNN (http://www.cnn.com), PageRank 9
- Yahoo US (http://www.yahoo.com), PageRank 10
- ESPN (http://www.espn.com), PageRank 8
- Wikipedia (http://www.wikipedia.org) , PageRank 8
New Zealand Websites:
- NZ Yahoo (http://nz.yahoo.com), PageRank 4
- NZ Herald (http://www.nzherald.co.nz), PageRank 8
- TV3 Website (http://www.tv3.co.nz), PageRank 6
As you can see, popular news Websites always get good PR, because a lot of other Websites link to them.
It is very easy to see PR of each page. Just to go Google’s Website (http://www.google.com/tools/firefox/toolbar/FT3/intl/en/index.html) and download the Google toolbar, install it, and then it will show you the Page Ranking of sites while you browse them.
Also the quality is more important than quantity, which means a PR4 website link to your website is better then 100 PR0 Websites linking to yours. If a high PR Website links to your Website, Google will treat it as a “high ranking Website voting for/recommending your website”, therefore you will gain trust from Google, which will result in an increase in your PageRanking. A visual example of this is shown below:

Image courtesy of www.smashingmagazine.com
To make your Website search engine optimized, PR is not the only thing you need to look after, but it is one very important part. Note that Google is not always updating your PageRanking, so you will not see instant results even you have a lot of Websites linking to you. Normally Google will update the Page Ranking across all sites every 2-3 months.
All MaxGen Media clients get links from our Website (PR4) and our tag Website (TagCloud), which benefits their rankings greatly. We also offer a link exchange system, which automatically makes links between your Website and all our clients’ Websites. We do this because we consider it vital that all our clients are represented as well as possible throughout the major search engines.
8 useful Search Engine Optimisation tips
Tags Dan,SEO,Website Development - posted by Daniel on 19 Jun, 2007 12:33 pm
As one of our new ‘informative’ blog segments, Daniel Chung presents an easy to follow breakdown of SEO tips. MaxGen Media actively employ all of these techniques when developing a Website.
Provide good digital content and services to your visitors
This is the most important part of SEO. Good content will not only increase your search engine ranking, but also give people the intention to make a link to your Website, because your Website is worthy to be recommended by other Website owners.
However, some SEO companies will introduce “cheat” SEO tactics to their customers. For example, they may put a lot of “hot” keywords on the Website and make text colour the same as background so it is invisible to your Website visitors, but still visible to search engines. Most search engines (Google, Yahoo, etc) are very aware of this, therefore the “cheat” action will result in lowering your search ranking, or even completely taking your site off search results.
Keep “ONE” domain name
You may have more than one domain name to your website, for instance, “yourwebsite.com” and “yourwebsite.co.nz”, but don’t submit both your domain names to search engines as they will treat these 2 domain names different Websites, even if it points to the same Website. Because people will visit your website from two different links, it will result in a failing to centralise your Website visitors, and the result will benefit nothing to your search engine ranking.
Focus your keywords
When you define your Website keywords, remember to Focus them. For example, if you are running a car dealer Website, you may use following terms to express your keyword “car” – “quality car”, “best car”, “budget car”, “cheap car”, etc. Doing this will not only confuse search engines, but also confuse your customers. So choose “one” keyword (in this case, lets choose “cheap car”) and make use of this keyword across the whole site.
Prepare a text version of your Website
Some people like “fully animated” Websites, which is very attractive and can impress your customers. However, not all search engines cannot dig through the content inside the animation, so it will result search engines treating your Website as an empty, and of course gaining no ranking.
If you do need a fully animated Website, also prepare a text version of it. See http://www.hms.harvard.edu/dcp/, they use Flash for their Website, but also place a link on top to which directs to a text version of the Website. In this case, search engines still be able to index all their content, while still maintaining the Flash animations.
Use “robots.txt” and robots META
- Place a “robots.txt”on your website root. It can tell how search engines dig through your Website.
- Place a “<META NAME=”ROBOTS” CONTENT=”ALL”> in head section of your website page. This will tell search engine dig through all your content, so no pages will be missed out.
Do not link to/with “bad” or ”unknown” Websites
There are a lots of “link farm” Websites, which allows you exchange links with all their members. Beware of this because you never know who will link to you, and who you link to, and it will affect your search engine ranking if you link to a lot of bad-quality Websites.
Submit your Website to directories and search engines:
- Submit your Website to ODP-DMOZ: http://www.dmoz.org/
- Submit your Website to Google: http://www.google.co.nz/addurl/?continue=/addurl
- Submit your Website to Xtra!Yahoo: http://nz.search.yahoo.com/freesubmit/submit
- Advertise on FINDA:
http://www.finda.co.nz/advertise-for-free/
Clean up your Website
- Make your Webpage file name related to the content
- Use CSS to define all your website layout / colour / fonts / etc.
- Make Javascript external links
- Make your Webpage less than 100k in size (not including picture/music, etc)
- Have no more than 100 links on each single page
- Create a sitemap page. It’s good for search engines to find all your Webpages
- Place most important keywords on your web browser title
- Place keywords in meta-tag keyword section (no more than 100 characters)
At MaxGen Media, we follow all search engine optimisation technologies to ensure your website is search engine friendly and can be easily found by your potential customers. Hope you enjoyed this overview of SEO. I’ll be posting more in the coming weeks.
Amazing Japanese Magican
Tags Dan,Obligatory Youtube Video - posted by Daniel on 25 May, 2007 05:57 pm
Check this out guys.

