<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dave PC Guy &#187; coupon</title>
	<atom:link href="http://www.davepcguy.com/archive/tag/coupon/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davepcguy.com</link>
	<description>Computers and Technology</description>
	<lastBuildDate>Fri, 08 Apr 2011 15:01:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Custom E-mail Form</title>
		<link>http://www.davepcguy.com/archive/custom-e-mail-form/</link>
		<comments>http://www.davepcguy.com/archive/custom-e-mail-form/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 19:14:43 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[PHP and Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[coupon]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web extras]]></category>

		<guid isPermaLink="false">http://www.davepcguy.com/?p=557</guid>
		<description><![CDATA[AH! So I have to create a custom e-mail sending form. He wants me to create a webform that will ask for a person&#8217;s name and e-mail address. Once those are input, an e-mail will be sent to the person&#8217;s e-mail account with a thank you message. Meanwhile, the website will reload with a custom]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;source=clrkmck&amp;style=normal&amp;service_api=clrkmck%3AR_a73f58a91ed3515157df75ab6c37730f&amp;hashtags=coupon,functions,mail,php,web+extras&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>AH! So I have to create a custom e-mail sending form. He wants me to create a webform that will ask for a person&#8217;s name and e-mail address. Once those are input, an e-mail will be sent to the person&#8217;s e-mail account with a thank you message. Meanwhile, the website will reload with a custom coupon that bears their name. I&#8217;ll need it printable so I&#8217;ll have to add a print button as well.<br />
Sounds simple enough, right?.. right?<br />
<span id="more-557"></span><br />
First off, go <a title="coupon tutorial" href="http://www.davepcguy.com/archive/coupon-design/">create a coupon</a>. After you&#8217;re done with that, we can start working. Make sure the &#8220;name&#8221; field is left out though, we&#8217;ll add that in later with some CSS. Originally, I wanted to send the coupon in the e-mail, forcing the customer to input the right e-mail address but I realized that most e-mail clients do not support CSS and especially not the &#8220;position: absolute;&#8221; property and value.<br />
<br />
<strong>Tip</strong>: I update the script periodically, and have numerous times while writing this tutorial. None of the scripts mentioned in this post are necessarily WRONG but at the bottom of the page is the current &#8220;release&#8221; that I&#8217;ve created. The images may not correspond directly with the code they represent.</p>
<h1>Setup</h1>
<p>Alright, here&#8217;s what you&#8217;ll need to do. You need to download MIME (MultiplePurpose Internet Mail Extensions), which is an e-mail extension for php that allows you to send HTML e-mails. If your site operates under c-panel, like mine is, then just scroll down, find the PHP extension icon. Search for &#8220;MIME&#8221; and install the packages. If you need to install them manually, search through google &#8220;Installing MIME on&#8221; your OS. I cannot really help you out more than that because I am not an expert on PHP extensions. There are multiple guides online though that WILL help you out.</p>
<div id="attachment_632" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/mail1.png"><img class="size-medium wp-image-632" title="mail1" src="http://www.davepcguy.com/wp-content/uploads/2009/10/mail1-300x105.png" alt="installing MIME" width="300" height="105" /></a><p class="wp-caption-text">installing MIME</p></div>
<div id="attachment_633" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/mail2.png"><img class="size-medium wp-image-633" title="mail2" src="http://www.davepcguy.com/wp-content/uploads/2009/10/mail2-300x54.png" alt="Press Install" width="300" height="54" /></a><p class="wp-caption-text">Press Install</p></div>
<p>Once you press install, the package will automatically install. It may ask if it can install other dependent packages, simply OK it.</p>
<h1>Basic Form</h1>
<div id="attachment_634" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/mail3.png"><img class="size-medium wp-image-634" title="mail3" src="http://www.davepcguy.com/wp-content/uploads/2009/10/mail3-300x185.png" alt="Modified Mail Form" width="300" height="185" /></a><p class="wp-caption-text">Modified Mail Form</p></div>
<p>Let&#8217;s start scripting. I advise you to create a mail.php form that you can &#8220;include ()&#8221; or &#8220;require()&#8221; into your existing website. It&#8217;s much neater this way and the PHP won&#8217;t get in the way of your layout. Here&#8217;s the basic form I created for our purposes:</p>
<pre class="brush: xml; title: ;">&lt;form action=&quot;&lt;?php $_SERVER['PHP_SELF'];?&gt;&quot; method=&quot;post&quot;&gt;
Name:&lt;br /&gt; &lt;input type=&quot;text&quot; name=&quot;name&quot; maxlength=&quot;41&quot; /&gt;&lt;br /&gt;
E-mail address:&lt;br /&gt; &lt;input type=&quot;text&quot; name=&quot;email&quot; maxlength=&quot;40&quot; /&gt;&lt;br /&gt;
Message (&lt;i&gt;optional&lt;/i&gt;):&lt;br /&gt; &lt;textarea name=&quot;optmessage&quot; cols=&quot;30&quot; rows&quot;10&quot; maxlength&quot;140&quot;&gt;&lt;/textarea&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;save&quot; /&gt;
&lt;/form&gt;</pre>
<p>I used the &#8220;$_SERVER['PHP_SELF']&#8221; variable for the action so that we won&#8217;t have to create yet another script page to use the information. The &#8220;name&#8221; field will translate to $_POST['name'], the&#8221;e-mail address&#8221; into $_POST['email'], and the optional &#8220;message&#8221; into $_POST['optmessage']. There is nothing much more to it. I used maxlength for the name 41 characters because my full fictional name, &#8220;Captain Soren William Alexander Janus VI.&#8221;, is exactly 41 characters long .  40 characters for the e-mail seems sufficient enough as well. 140 character message is the same as twitter&#8217;s max tweet. There is nothing much else to this.</p>
<h1>Are you feeling &#8220;Loopy&#8221;?</h1>
<p>Let&#8217;s move on. We need to create a loop that will ensure our data has been entered and that we are not dealing with a blank form. The purpose of this basic loop is to show the initial form for the user to submit the data to, reload the form if any errors were made during submission (ie invalid entries), and send the email in the end.</p>
<pre class="brush: php; title: ;">
&lt;?php
if (!isset($_POST['submit']) { ?&gt;

Form goes here

&lt;?php } elseif (empty($_POST['email']) || empty($_POST['name']) ||
(isEmailAddress($_POST['email']) == 0) || (trim($_POST['email']) == '')
|| (trim($_POST['name']) == '')) {
?&gt;

Something entered was wrong, please re-enter your information:
form goes here.

&lt;?php }
else {
store variables, send e-mail, and show a new page with a coupon }
?&gt;
</pre>
<p>Confused? Don&#8217;t be. The beginning tells us if the form has been previously submitted, if not, the form will load. The second part after &#8220;elseif&#8221; checks if all the data entered is correct. After all the conditions have been met, we progress to the last &#8220;else&#8221; which will execute the mail sending.</p>
<h1>&#8220;Validate This!&#8221;</h1>
<p>If you look above, you&#8217;ll see a strange function called &#8220;isEmailAddress&#8221;. I set this function up using a script I <a title="validation scripts" href="http://devzone.zend.com/node/view/id/662">found</a>. Here is the function:</p>
<pre class="brush: php; title: ;">
function isEmailAddress($value) {
        return eregi('^([a-z0-9])+([\.a-z0-9_-])*@([a-z0-9_-])+(\.[a-z0-9_-]+)*\.([a-z]{2,6})$', $value);
    }
	</pre>
<p>It basically checks if the e-mail is in the correct format. It also makes sure that only a single e-mail address has been entered and that it does not contain any malicious code.</p>
<p><strong>Tip</strong>: If you wish to add database support to this script, you&#8217;ll have to use a validation function for the name and message as well!</p>
<p>Next part of validation are the &#8220;empty()&#8221; and &#8220;trim()&#8221; functions. &#8220;Empty()&#8221; is self-explanatory. You entered the variable name and the function will check if it is empty or not. If it is, the function returns TRUE. &#8220;Trim()&#8221; works similarly except here it takes out all the extra spaces and such. If it equals &#8216; &#8216; or an empty space, then it will return TRUE. The &#8220;elseif&#8221; statement is setup so that it checks the e-mail and name value.</p>
<p><strong>Tip: </strong>If you have some time on your hand you can create a function that will check for each of these statements like: function CheckValue ($var) { if (empty($var) {return TRUE;} if (trim($var) == &#8216; &#8216;) { return TRUE;} }</p>
<h1>Second Form</h1>
<div id="attachment_635" class="wp-caption aligncenter" style="width: 302px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/mail4.png"><img class="size-full wp-image-635" title="mail4" src="http://www.davepcguy.com/wp-content/uploads/2009/10/mail4.png" alt="Incorrect entry" width="292" height="265" /></a><p class="wp-caption-text">Incorrect entry</p></div>
<p>You have a choice here. Under &#8220;elseif ()&#8221;, you can create new &#8220;if&#8221; statements and inform the user of what exactly is wrong. For example if the name is empty, you can create an if statement like this:</p>
<pre class="brush: php; title: ;">
if (empty($_POST['name'] || trim($_POST['name']) == ' ') { ?&gt;
 echo &quot;You left the name field empty&quot;;
&lt;?php } ?&gt;
</pre>
<p>I like to keep the user in the shadows and put all of the validation together using the || which means &#8220;or&#8221; and the same original form will show up with the message &#8220;Error: Please enter a valid e-mail address and your name&#8221;. Add the following form under &#8220;elseif()&#8221; between the php tags:</p>
<pre class="brush: xml; title: ;">
Error: Please enter a valid e-mail address and your name

&lt;form action=&quot;&lt;?php $_SERVER['PHP_SELF'];?&gt;&quot; method=&quot;post&quot;&gt;
Name:&lt;br /&gt; &lt;input type=&quot;text&quot; name=&quot;name&quot; maxlength=&quot;41&quot; /&gt;&lt;br /&gt;
E-mail address:&lt;br /&gt; &lt;input type=&quot;text&quot; name=&quot;email&quot; maxlength=&quot;40&quot; /&gt;&lt;br /&gt;
Message (&lt;i&gt;optional&lt;/i&gt;):&lt;br /&gt; &lt;textarea name=&quot;optmessage&quot; cols=&quot;30&quot; rows&quot;10&quot; maxlength&quot;140&quot;&gt;&lt;/textarea&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
&lt;/form&gt;
</pre>
<p>It&#8217;s the same form with a little message on top.</p>
<h1>Everything &#8220;Else&#8221;</h1>
<p>So all the variables go through, the script is validated. What now then? Now we&#8217;ll send the e-mail and refresh the site. I am using e-mails for a good reason. Whenever a user asks for a coupon, I&#8217;ll have a copy of their name and their e-mail address for future reference. I COULD use a database system but I&#8217;m a lazy person. I&#8217;ll point you in the right direction if you wish to do that though. Instead, let&#8217;s focus on what I already have done.</p>
<p>We should set up our variables first, writing out $_POST['email'] is quite a hassle. Plus, we have to set up the e-mail variables as well. Also note that this is in the last else {} section:</p>
<pre class="brush: php; title: ;">
//variables

$to = $_POST['email'];
$subject = &quot;Coupon from the Chiropractors&quot;;
$name = $_POST['name'];
$optmessage= $_POST['optmessage'];
$opt = wordwrap ($optmessage, 70);
</pre>
<p>The mail function works like this:</p>
<blockquote><p>mail (to, subject, message, headers)</p></blockquote>
<p>So we set up the &#8220;$to&#8221; variable which we will direct to the e-mail. We&#8217;ve also set up the subject of the e-mail and put $_POST['name'] into the $name variable for later use. Next, I transferred the optional message into $optmessage variable which I then word-wrapped into $opt. You have to word-wrap your e-mail message and the longest line can only have 70 characters. Using the &#8220;wordwrap ()&#8221; function and the parameter &#8220;70&#8243;, we&#8217;ve accomplished that. Let&#8217;s write the message:</p>
<pre class="brush: php; title: ;">
$message = &quot;&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=\&quot;Content-Type\&quot; content=\&quot;text/html; charset=utf-8\&quot; /&gt;
&lt;title&gt;Chiropractic&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;p&gt; Dear $name,&lt;br /&gt;
Thank you for visiting us at our&lt;a href=\&quot;http://www.davepcguy.com\&quot;&gt;Website&lt;/a&gt;.
&lt;p&gt; Please print out your coupon and present it on your next visit. Thank you, and we hope to see you soon!&lt;/p&gt;
&lt;p style=\&quot;margin-left: 50px\&quot;&gt; Sincerely, Alexander &lt;/p&gt;
&lt;p&gt;optional message:&lt;br /&gt;
$opt&lt;/p&gt;
&lt;p&gt;
Your e-mail: $to &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;&quot;;
</pre>
<p>Note that e-mail clients have different <a title="CSS support for different e-mail clients" href="http://www.campaignmonitor.com/css/">support</a> of HTML and CSS. Don&#8217;t include any XHTML, that&#8217;s way too complicated. This is the reason why I did not put the coupon into the e-mail. Most e-mail clients do not support the &#8220;position: absolute&#8221;. Alright, let&#8217;s setup our header variable. With headers, you can define who the e-mail is from, where to reply to the e-mail, send different copies, and most importantly, use MIME.</p>
<pre class="brush: php; title: ;">
 //header information
$from = &quot;no-reply@davepcguy.com&quot;;
$headers = &quot;From: $from&quot; . &quot;\r\n&quot;;
$headers .= 'MIME-Version: 1.5.2' . &quot;\r\n&quot;;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . &quot;\r\n&quot;;
$headers .= &quot;BCC: reply@davepcguy.com&quot; . &quot;\r\n&quot;;
</pre>
<p>I used an e-mail address I set up through c-panel. Set it up the same way you set up any other e-mail account. And you won&#8217;t even have to include the password in your script. Let&#8217;s break down the header.</p>
<p>The first header establishes from where the e-mail will be sent. Always break the lines when setting up the header variable using &#8220;\r\n&#8221;. Next, set up your MIME and its version. The newest one should be 1.5.2 but check your version under the PHP addons/modules in your c-panel. If you can&#8217;t make it work, use &#8220;MIME-Version: 1.0&#8243;. Next, set the content-type. Just copy the above, there should be no other alternative. The script will also send a BCC (Blind Carbon Copy) of every e-mail to my own e-mail address so that I can keep records. Let&#8217;s send it then!</p>
<pre class="brush: php; title: ;">
//functions
$mail_sent= mail(&quot;$to&quot;, $subject, $message, $headers);
</pre>
<p>All that work and it&#8217;s summed up in one single line, amazing, eh?</p>
<h1>The Script After</h1>
<p>Hmm&#8230;I think I should give the user the coupon finally, don&#8217;t you think? They&#8217;ve done SO much work. Well, let me set up the message then:</p>
<pre class="brush: php; title: ;">
//announcement
$sent= &quot;
&lt;p&gt; Dear $name,&lt;br /&gt;
Thank you for visiting us at &lt;a href=\&quot;http://www.davepcguy.com\&quot;&gt;Website&lt;/a&gt;
Here is your coupon&lt;/p&gt;
&lt;div align=\&quot;center\&quot; style=\&quot;padding=\&quot;50px\&quot;&gt;
&lt;div style=\&quot;position: absolute; margin: 75px 120px 10px 50px; font-size: 30px; border-bottom: 2px solid black; width: 250px\&quot;&gt; $name &lt;/div&gt;
&lt;img src=\&quot;coupon2.png\&quot; width=\&quot;436\&quot; height=\&quot;292\&quot; /&gt;&lt;/div&gt;
&lt;p&gt; Please print this coupon out and present it on your next visit. Thank you, and we hope to see you soon!&lt;/p&gt;
&lt;p style=\&quot;margin-left: 50px\&quot;&gt; Sincerely, Alexander &lt;/p&gt;
&lt;p&gt; P.S. please print out your coupon immediately or save this page because it will not be available after you close out.
If you're having any trouble, please contact our &lt;a href=\&quot;mailto:alexander@davepcguy.com\&quot;&gt;webmaster&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Optional Message: &lt;br /&gt;
$opt
&lt;/p&gt;
&quot;;
echo $mail_sent ? $sent : &quot;Mail failed&quot;;
echo $sent;
}
?&gt;
</pre>
<p>Haha, I know, it looks complicated, doesn&#8217;t it? Well not really, the &#8220;$sent&#8221; just sets up a variable with the html code I plan to use in my webpage. Beware, you&#8217;ll have to adjust this according to your own webpage. the echo $mail_sent ? $sent: &#8220;Mail failed&#8221;; is a short hand for an if loop &#8221; if ($mail_sent) {$sent} else { &#8220;Mail Failed&#8221;};&#8221; then the $sent variable will echo out.</p>
<div id="attachment_636" class="wp-caption aligncenter" style="width: 280px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/mail5.png"><img class="size-medium wp-image-636" title="mail5" src="http://www.davepcguy.com/wp-content/uploads/2009/10/mail5-270x300.png" alt="final page" width="270" height="300" /></a><p class="wp-caption-text">final page</p></div>
<h1>Extras</h1>
<ul>
<li>database support</li>
<li>print</li>
<li>extra validation</li>
</ul>
<p>This is how I finished out my script. I don&#8217;t plan on doing too much to it other than making it printable. I&#8217;m thinking about making a pop-up window that will display all of that information. Let&#8217;s review some of the extras you can add.</p>
<p><strong>Database Support </strong>First, you can add database support. Simply make a new database in MySQL (using PHPmyAdmin) and set up two columns, one for name, and the other for name. Set up the table or use this SQL command if you can, creating the database might be tricky, but you should be able to use the &#8220;CREATE TABLE&#8221; part. If you can&#8217;t, just set it up manually using the values shown:</p>
<pre>CREATE DATABASE coupondb;

CREATE TABLE `coupons` (
    `id` int(11) NOT NULL auto_increment,
    `name` varchar(255) NOT NULL default '',
    `email` varchar(255) NOT NULL default '',
    PRIMARY KEY  (`id`)
) TYPE=MyISAM;</pre>
<p>You can probably make a third column for an order (1., 2., 3.) or for the date and time. Add this at the beginning of the &#8220;else{}&#8221; :</p>
<pre class="brush: php; title: ;">
//MySQL variable
$host = &quot;localhost&quot;;
$user = &quot;user&quot;;
$pass = &quot;password&quot;;
$db = &quot;coupondb&quot;;

//connect
$connection = mysql_connect($host, $user, $pass) or die (&quot;Unable to connect!&quot;);

// select database
mysql_select_db($db) or die (&quot;Unable to select database!&quot;);
</pre>
<p>First, set up the host variable ie, where the database is. I&#8217;ll trust my WordPress senses and leave that with localhost. You&#8217;ll have to create a new username and password as well as a database manually using c-panel or a different site manager your hosting provides you. Input the user and password. Change the &#8220;die&#8221; variable to something like &#8220;internal server error&#8221; or something, this is just for educational purposes. I got it off <a title="Database Tutorial Zend" href="http://devzone.zend.com/node/view/id/641">Zend Dev Zone </a>again. Make sure you put this BEFORE the e-mail sending (ie the mail() function) because it&#8217;s senseless to send the e-mail but not make a database entry. Here&#8217;s the basic query:</p>
<pre class="brush: php; title: ;">
 // create query
    $query = &quot;INSERT INTO coupons (name, email) VALUES ('$name', '$to')&quot;;

    // execute query
    $result = mysql_query($query) or die (&quot;Error in query: $query. &quot;.mysql_error());

    // close connection
    mysql_close($connection);
</pre>
<p>And there you go, database support added. Check out my full script on the bottom for the full implementation with the duplicate entries check as well as other features.</p>
<p><strong>Print </strong><img src="file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/moz-screenshot.png" alt="" />Let&#8217;s check out how to print all this stuff out. I found a neat piece of JavaScript that can accomplish this. It&#8217;s a bit tricky and I still can&#8217;t get it to show the best results but, it seems to work well nonetheless. You can find it <a title="javascript print code" href="http://personalweb.about.com/od/copypastejavascripts/a/404_3scripts_3.htm">here</a>. Add the header part into the real header where you&#8217;ll use this mail.php script. Then, modify the $sent variable:</p>
<pre class="brush: php; title: ;">
$sent= &quot;&lt;div id=\&quot;printReady\&quot;&gt;
&lt;div style=\&quot; width: 457px; background: white; text-align: center\&quot;&gt;
&lt;p&gt; Dear $name,&lt;br /&gt;
Thank you for visiting us at &lt;a href=\&quot;http://www.davepcguy.com\&quot;&gt;Website&lt;/a&gt;
Here is your coupon&lt;/p&gt;
&lt;div align=\&quot;center\&quot; style=\&quot;padding=\&quot;50px\&quot;&gt;
&lt;div style=\&quot;position: absolute; margin: 75px 120px 10px 50px; font-size: 30px; border-bottom: 2px solid black; width: 250px\&quot;&gt; $name &lt;/div&gt;
&lt;img src=\&quot;coupon2.png\&quot; width=\&quot;436\&quot; height=\&quot;292\&quot; /&gt;&lt;/div&gt;
&lt;p&gt; Please print this coupon out and present it on your next visit. Thank you, and we hope to see you soon!&lt;/p&gt;
&lt;p style=\&quot;margin-left: 50px\&quot;&gt; Sincerely, Alexander &lt;/p&gt;
&lt;p&gt; P.S. please print out your coupon immediately or save this page because it will not be available after you close out.
If you're having any trouble, please contact our &lt;a href=\&quot;mailto:alexander@davepcguy.com\&quot;&gt;webmaster&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Optional Message: &lt;br /&gt;
$opt
&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
&lt;form id=\&quot;printMe\&quot; name=\&quot;printMe\&quot;&gt;  &lt;input type=\&quot;button\&quot; name=\&quot;printMe\&quot; onClick=\&quot;printSpecial()\&quot; value=\&quot;Print this Page\&quot;&gt; &lt;/form&gt;
&quot;;</pre>
<p>Change the width to suit your needs. And I am completely aware there is a million different divs just in this script (you should see the pages I code, million more divs) but they are mostly mandatory. You can switch the &#8220;div&#8221; around the &#8220;$name&#8221; variable to &lt;span&gt;. You&#8217;ll have to spend some time adjusting this, the width of the page, the margin, as well as the different positions to suit your needs. It worked for me almost perfectly <img src='http://www.davepcguy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Extra Validation</strong> Okay, so if you want to use a database with this form, you&#8217;ll need some extra validation as a precaution against SQL injection. We&#8217;ve already validated the e-mail address and I won&#8217;t be validating the optional message just yet. So let&#8217;s validate the name. I used a function from the same script I cited when I used the e-mail validation function:</p>
<pre class="brush: php; title: ;">
// check whether input is alphabetic
    function isAlpha($value) {
        return preg_match('/^[a-zA-Z]+$/', $value);
    }
</pre>
<p>Add this function to the beginning of the document and add another || to the elseif () {} part of the loop saying &#8220;!isAlpha($_POST['name'])&#8221;. Also, warn the user that they can use only letters for the name and no periods or other characters nor numbers. The optional message SHOULD be validated but I am not certain how to go about it just yet. I&#8217;d like to let the user be able to use some personalized html code so I won&#8217;t look into it too much. Also, I am not storing that message so I don&#8217;t have to fear an SQL attack.</p>
<h1>Conclusion</h1>
<p>I hope this shed some light on how you&#8217;d create an e-mail form as well as how to use the mail() function. As you can see, the possibilities with PHP are endless. I&#8217;d like to also inform you that it took me several hours to write this script with numerous trial&amp;error runs. I&#8217;m self-taught, and mostly used the <a title="PHP manual" href="http://php.net/manual/en/index.php">PHP manual</a> as a reference. I hope this helped and that you have fun trying this out for yourselves!</p>
<p>I&#8217;d appreciate any comments regarding the security of this script as well as usability. I, myself, am about to launch the script on one of my pages so I&#8217;d like to know what people have to say about it.</p>
<p>Final Script with all its features added: Note that I will update this part of the post as necessary when I find bugs and optimize it.</p>
<pre class="brush: php; title: ;">

&lt;?php
//functions
/* PHP script written by Alexander Janus
contact: alexander@davepcguy.com
blog: http://www.davepcguy.com
if you want to use this script, include this header
*/
function isEmailAddress($value) {
 return eregi('^([a-z0-9])+([\.a-z0-9_-])*@([a-z0-9_-])+(\.[a-z0-9_-]+)*\.([a-z]{2,6})$', $value);
 }
// check whether input is alphabetic
function isAlpha($value) {
 return preg_match('/^[a-zA-Z]+$/', $value);
 }

function name ($var) {
 if (!isset($var)){
 return TRUE;
 }
 if (empty($var)){
 return TRUE;
 }
 if (trim($var) == ''){
 return TRUE;
 }
 if (isAlpha($var) == 0){
 return TRUE;
 }
}
function email ($var) {
 if (!isset($var)){
 return TRUE;
 }
 if (empty($var)){
 return TRUE;
 }
 if (trim($var) == ''){
 return TRUE;
 }
 if (isEmailAddress($var) == 0){
 return TRUE;
 }
}

//loop
if(!isset($_POST['submit'])){

 ?&gt;
Please enter your name and e-mail address. The name field supports only alphabetic characters (letters).
&lt;form action=&quot;&lt;?php $_SERVER['PHP_SELF'];?&gt;&quot; method=&quot;post&quot;&gt;
Name:&lt;br /&gt; &lt;input type=&quot;text&quot; name=&quot;name&quot; maxlength=&quot;41&quot; /&gt;&lt;br /&gt;
E-mail address:&lt;br /&gt; &lt;input type=&quot;text&quot; name=&quot;email&quot; maxlength=&quot;40&quot; /&gt;&lt;br /&gt;
Message (&lt;i&gt;optional&lt;/i&gt;):&lt;br /&gt; &lt;textarea name=&quot;optmessage&quot; cols=&quot;30&quot; rows&quot;10&quot; maxlength&quot;140&quot;&gt;&lt;/textarea&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
&lt;/form&gt;

&lt;?php
}

elseif (name($_POST['name']) || email($_POST['email'])) {
 if (name($_POST['name'])) {
 echo &quot;Please enter a valid name. Periods, commas, or other non-alpha characters are not supported.&lt;br/&gt;&quot;;
 }
 if (email($_POST['email'])){
 echo &quot;Please enter a valid e-mail address in this format: account@email.com. &lt;br /&gt;&quot;;}
?&gt;

&lt;form action=&quot;&lt;?php $_SERVER['PHP_SELF'];?&gt;&quot; method=&quot;post&quot;&gt;
Name:&lt;br /&gt; &lt;input type=&quot;text&quot; name=&quot;name&quot; maxlength=&quot;41&quot; /&gt;&lt;br /&gt;
E-mail address:&lt;br /&gt; &lt;input type=&quot;text&quot; name=&quot;email&quot; maxlength=&quot;40&quot; /&gt;&lt;br /&gt;
Message (&lt;i&gt;optional&lt;/i&gt;):&lt;br /&gt; &lt;textarea name=&quot;optmessage&quot; cols=&quot;30&quot; rows&quot;10&quot; maxlength&quot;140&quot;&gt;&lt;/textarea&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
&lt;/form&gt;
 &lt;?php

}
else {
//Database connection
//MySQL variable
$host = &quot;localhost&quot;;
$user = &quot;user&quot;;
$pass = &quot;password&quot;;
$db = &quot;coupon&quot;;

//connect
$connection = mysql_connect($host, $user, $pass) or die (&quot;Unable to connect!&quot;);

// select database
mysql_select_db($db) or die (&quot;Unable to select database!&quot;);

//variables

$to = $_POST['email'];
$subject = &quot;Coupon from the Chiropractors&quot;;
$name = $_POST['name'];
$optmessage= $_POST['optmessage'];
$opt = wordwrap ($optmessage, 70);
$sent= &quot;&lt;div id=\&quot;printReady\&quot;&gt;
&lt;div style=\&quot; width: 457px; background: white; text-align: center;\&quot;&gt;
&lt;p&gt; Dear $name,&lt;br /&gt;
Thank you for visiting us at &lt;a href=\&quot;http://www.davepcguy.com\&quot;&gt;Website&lt;/a&gt;
Here is your coupon&lt;/p&gt;
&lt;div align=\&quot;center\&quot; style=\&quot;padding=\&quot;50px\&quot;&gt;
&lt;span style=\&quot;position: absolute; margin: 75px 120px 10px 50px; font-size: 30px; border-bottom: 2px solid black; width: 250px\&quot;&gt; $name &lt;/span&gt;
&lt;img src=\&quot;coupon2.png\&quot; width=\&quot;436\&quot; height=\&quot;292\&quot; /&gt;&lt;/div&gt;
&lt;p&gt; Please print this coupon out and present it on your next visit. Thank you, and we hope to see you soon!&lt;/p&gt;
&lt;p style=\&quot;margin-left: 50px\&quot;&gt; Sincerely, Alexander &lt;/p&gt;
&lt;p&gt; P.S. please print out your coupon immediately or save this page because it will not be available after you close out.
If you're having any trouble, please contact our &lt;a href=\&quot;mailto:alexander@davepcguy.com\&quot;&gt;webmaster&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Optional Message: &lt;br /&gt;
$opt
&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
&lt;form id=\&quot;printMe\&quot; name=\&quot;printMe\&quot;&gt;  &lt;input type=\&quot;button\&quot; name=\&quot;printMe\&quot; onClick=\&quot;printSpecial()\&quot; value=\&quot;Print this Page\&quot;&gt; &lt;/form&gt;
&quot;;

//MYSQL QUERY
//check for duplicates
$duplicate = mysql_query(&quot;SELECT * FROM coupons where email='$to'&quot;);
$affected_rows = mysql_num_rows($duplicate);
if($affected_rows &gt;= 1)
{
echo $sent;
echo &quot;&lt;span style=\&quot;color: red;\&quot;&gt;Note: If you have already entered your e-mail address before, you will not get another e-mail message. &lt;br /&gt;
This is to prevent spamming.&lt;/span&gt;&quot;;
die('');
}
else {
// create query
 $query = &quot;INSERT INTO coupons (name, email) VALUES ('$name', '$to')&quot;;

 // execute query
 $result = mysql_query($query) or die (&quot;Error in query: $query. &quot;.mysql_error());

 // close connection
 mysql_close($connection);

}

//html message
$message = &quot;&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=\&quot;Content-Type\&quot; content=\&quot;text/html; charset=utf-8\&quot; /&gt;
&lt;title&gt;Chiropractic&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;p&gt; Dear $name,&lt;br /&gt;
Thank you for visiting us at our&lt;a href=\&quot;http://www.davepcguy.com\&quot;&gt;Website&lt;/a&gt;
&lt;p&gt; Please print out your coupon and present it on your next visit. Thank you, and we hope to see you soon!&lt;/p&gt;
&lt;p style=\&quot;margin-left: 50px\&quot;&gt; Sincerely, Alexander &lt;/p&gt;
&lt;p&gt;optional message:&lt;br /&gt;
$opt&lt;/p&gt;
&lt;p&gt;
Your e-mail: $to &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;&quot;;

 //header information
$from = &quot;no-reply@davepcguy.com&quot;;
$headers = &quot;From: $from&quot; . &quot;\r\n&quot;;
$headers .= 'MIME-Version: 1.5.2' . &quot;\r\n&quot;;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . &quot;\r\n&quot;;
$headers .= &quot;BCC: reply@davepcguy.com&quot; . &quot;\r\n&quot;;

//functions
$mail_sent= mail(&quot;$to&quot;, $subject, $message, $headers);

//announcement

echo $mail_sent ? $sent : &quot;Mail failed&quot;;
echo $sent;
}

?&gt;
</pre>




Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;partner=sociable" title="Print"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;title=Custom%20E-mail%20Form&amp;bodytext=AH%21%20So%20I%20have%20to%20create%20a%20custom%20e-mail%20sending%20form.%20He%20wants%20me%20to%20create%20a%20webform%20that%20will%20ask%20for%20a%20person%27s%20name%20and%20e-mail%20address.%20Once%20those%20are%20input%2C%20an%20e-mail%20will%20be%20sent%20to%20the%20person%27s%20e-mail%20account%20with%20a%20thank%20you%20message.%20Meanwhil" title="Digg"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;title=Custom%20E-mail%20Form&amp;notes=AH%21%20So%20I%20have%20to%20create%20a%20custom%20e-mail%20sending%20form.%20He%20wants%20me%20to%20create%20a%20webform%20that%20will%20ask%20for%20a%20person%27s%20name%20and%20e-mail%20address.%20Once%20those%20are%20input%2C%20an%20e-mail%20will%20be%20sent%20to%20the%20person%27s%20e-mail%20account%20with%20a%20thank%20you%20message.%20Meanwhil" title="del.icio.us"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;t=Custom%20E-mail%20Form" title="Facebook"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;title=Custom%20E-mail%20Form&amp;annotation=AH%21%20So%20I%20have%20to%20create%20a%20custom%20e-mail%20sending%20form.%20He%20wants%20me%20to%20create%20a%20webform%20that%20will%20ask%20for%20a%20person%27s%20name%20and%20e-mail%20address.%20Once%20those%20are%20input%2C%20an%20e-mail%20will%20be%20sent%20to%20the%20person%27s%20e-mail%20account%20with%20a%20thank%20you%20message.%20Meanwhil" title="Google Bookmarks"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;title=Custom%20E-mail%20Form&amp;source=Dave+PC+Guy+Computers+and+Technology&amp;summary=AH%21%20So%20I%20have%20to%20create%20a%20custom%20e-mail%20sending%20form.%20He%20wants%20me%20to%20create%20a%20webform%20that%20will%20ask%20for%20a%20person%27s%20name%20and%20e-mail%20address.%20Once%20those%20are%20input%2C%20an%20e-mail%20will%20be%20sent%20to%20the%20person%27s%20e-mail%20account%20with%20a%20thank%20you%20message.%20Meanwhil" title="LinkedIn"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;title=Custom%20E-mail%20Form" title="Reddit"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;t=Custom%20E-mail%20Form&amp;s=AH%21%20So%20I%20have%20to%20create%20a%20custom%20e-mail%20sending%20form.%20He%20wants%20me%20to%20create%20a%20webform%20that%20will%20ask%20for%20a%20person%27s%20name%20and%20e-mail%20address.%20Once%20those%20are%20input%2C%20an%20e-mail%20will%20be%20sent%20to%20the%20person%27s%20e-mail%20account%20with%20a%20thank%20you%20message.%20Meanwhil" title="Tumblr"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Custom%20E-mail%20Form%20-%20http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F" title="Twitter"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Custom%20E-mail%20Form&amp;body=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F" title="email"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Custom%20E-mail%20Form&amp;url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F" title="Slashdot"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcustom-e-mail-form%2F&amp;title=Custom%20E-mail%20Form" title="StumbleUpon"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.davepcguy.com/archive/custom-e-mail-form/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Coupon design</title>
		<link>http://www.davepcguy.com/archive/coupon-design/</link>
		<comments>http://www.davepcguy.com/archive/coupon-design/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 00:32:39 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[coupon]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[illustrator]]></category>
		<category><![CDATA[logo]]></category>

		<guid isPermaLink="false">http://www.davepcguy.com/?p=526</guid>
		<description><![CDATA[Remember a couple weeks ago I mentioned I would be making a website for a chiropractor? Well, here it is. I finally got my client to approve the hosting and the domain. I&#8217;m using JustHost for the hosting and I installed a preliminary wordpress template. It&#8217;s the easiest way to start up a website. I]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;source=clrkmck&amp;style=normal&amp;service_api=clrkmck%3AR_a73f58a91ed3515157df75ab6c37730f&amp;hashtags=coupon,Design,fonts,illustrator,logo&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Remember a couple weeks ago I mentioned I would be making a website for a chiropractor? Well, here it is. I finally got my client to approve the hosting and the domain. I&#8217;m using <a href="http://www.justhost.com">JustHost</a> for the hosting and I installed a preliminary wordpress template. It&#8217;s the easiest way to start up a website. I used a free template I found online.</p>
<p>My client does not wish to have a blog, of course, so I&#8217;ll be creating a static website soon enough. Anyways, one of the things my client wants me to do is make coupons, so let&#8217;s do that!</p>
<p>My plan is to hopefully create a nice vector coupon design in illustrator, make a PHP script that will send it to a recipient&#8217;s e-mail with THEIR name on it. I&#8217;m not sure how I&#8217;ll be able to do that cross-browser and all that but we&#8217;ll make it together!<br />
<span id="more-526"></span></p>
<h1>Coupon</h1>
<p>Let&#8217;s start with the design. I want it to be large enough so that it basically renders a print page useless. If it&#8217;s too small, I always feel like I&#8217;m wasting a lot of paper just to print one thing so if it&#8217;s large enough, it doesn&#8217;t feel like such a waste. I&#8217;m thinking it should be about as large as an index card, maybe a bit larger.</p>
<div id="attachment_565" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/1.png"><img class="size-medium wp-image-565" title="Setup" src="http://www.davepcguy.com/wp-content/uploads/2009/10/1-300x193.png" alt="1" width="300" height="193" /></a><p class="wp-caption-text">Document Setup</p></div>
<p style="text-align: center;">
<p>I created the new document with a 4&#215;6 dimensions (6&#215;4 when viewed this way). I started up with the little rectangle that signifies the size of my image. Now, let&#8217;s turn on the grid by going to view &gt; show grid, and view &gt; snap to grid.</p>
<div id="attachment_566" class="wp-caption aligncenter" style="width: 213px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/2.png"><img class="size-full wp-image-566 " title="Rounded Rectangle Tool" src="http://www.davepcguy.com/wp-content/uploads/2009/10/2.png" alt="Rounded Rectangle Tool" width="203" height="150" /></a><p class="wp-caption-text">Rounded Rectangle Tool</p></div>
<p style="text-align: left;">Next, let&#8217;s make an actual rectangle in the image. I used the rounded rectangle tool. Because of the &#8220;snap to grid&#8221;, you&#8217;ll be able to start exactly on the top-left corner and drag all the way to the bottom-right corner in one single stroke. Leave your mouse clicked and press either the top or bottom arrow to make the corners more or less rounded. I like them rounded just enough so that they leave one square of the grid uncovered in the corners. Let go and you&#8217;ll have a nice rectangular base we can start working on.</p>
<div id="attachment_567" class="wp-caption aligncenter" style="width: 160px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/3.png"><img class="size-thumbnail wp-image-567 " title="no fill" src="http://www.davepcguy.com/wp-content/uploads/2009/10/3-150x97.png" alt="no fill" width="150" height="97" /></a><p class="wp-caption-text">no fill</p></div>
<p style="text-align: left;">Click on the rectangle and switch to no-fill (the circled square above) while clicking on the fill palette. This makes sure there will no background. Make sure your stroke is black (palette to the right) and 1pt wide. This should be your result so far:</p>
<p style="text-align: center;">
<div id="attachment_568" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/4.png"><img class="size-medium wp-image-568 " title="progress 1" src="http://www.davepcguy.com/wp-content/uploads/2009/10/4-300x205.png" alt="progress 1" width="300" height="205" /></a><p class="wp-caption-text">progress 1</p></div>
<p>Ah, the hard part is over! Haha, just kidding. Alright, well you see the square grid? Let&#8217;s add a couple of elements. I want to include a small text on the bottom that will explain limits of the coupon. I created a guide that&#8217;s two squares from the left and another guide two squares from the right. To create a guide, go to view&gt;rulers and then simply drag from the left or the top, right or down, and you should see a guide. Leave it where you please. I started typing the small texts four squares from the bottom (no guide required). I used Myriad Pro and a 12pt font with a center alignment. Tip: start typing where the middle grid-line is. I typed two lines of text and here&#8217;s my result:</p>
<div id="attachment_569" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/5.png"><img class="size-medium wp-image-569" title="small text" src="http://www.davepcguy.com/wp-content/uploads/2009/10/5-300x40.png" alt="small text" width="300" height="40" /></a><p class="wp-caption-text">small text</p></div>
<p>Next let&#8217;s add the title of the company. I created another guide that&#8217;s right where the first grey grid line from the top is or the 3-inch marker. I started the text one square below the top and the text-box one square from each side. Text is center-aligned, Myriad Pro, and with a 36pt value. After I added the title, I added a second part of the title. The name of the company is&#8221;Georgia Chiropractic Group&#8221;, and the name of the practice is &#8220;at Sixes Road.&#8221; I added this text one square to the left of the center vertical line and one square above the guide. I used Myriad Pro, left aligned, and with a 24pt font. Next, I added a circle with its origin five and a half squares to the left of the right side and on the guide line and it&#8217;s three and a half squares long in its radius. Here&#8217;s the result:</p>
<div id="attachment_570" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/6.png"><img class="size-medium wp-image-570" title="title" src="http://www.davepcguy.com/wp-content/uploads/2009/10/6-300x82.png" alt="title" width="300" height="82" /></a><p class="wp-caption-text">title</p></div>
<p>Let&#8217;s add the name part. I want to create a custom coupon for each customer (using a php script and some CSS in my next tutorial) so I need to create a name field. Originally, I intended to have the name above a line, but I found it cumbersome, especially with the use of CSS and PHP so I think all I need for now is just a place holder. I used a rectangle with a one point stroke and placed it one square below our horizontal guide and started the rectangle two squares right from the left side (our left vertical guide). The box reaches the second thicker grid-line left from the right side. I added a name and the underline for demonstrational purposes only. Here&#8217;s the result:</p>
<div id="attachment_571" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/7.png"><img class="size-medium wp-image-571" title="namebox" src="http://www.davepcguy.com/wp-content/uploads/2009/10/7-300x102.png" alt="name box" width="300" height="102" /></a><p class="wp-caption-text">name box</p></div>
<p>So far so good, now let&#8217;s added the phone number and the address of the business. If, for some reason, your business does not have a single address or a phone number, you can add  mock <a title="barcode generator" href="http://www.terryburton.co.uk/barcodewriter/generator/">barcode. </a>If you need the barcode AND the address, you&#8217;ll probably have to shrink the box where the name goes, and shrink the &#8220;purpose-text&#8221; of the coupon as well. I want the coupon to say &#8220;$25 Adjustment&#8221;, if your coupon is supposed to say &#8220;$25 off&#8221;, it will take up less space and thus allow you to fit in the barcode. Another alternative way is to shrink the logo, or put the logo as a background to the name box, or any other part of the coupon, such as the &#8220;purpose text&#8221; itself.<br />
<br />
Anyways,  I added the address two squares below the textbox and the phone number two squares below the address. And again, I followed the left vertical guide we set up earlier. Here&#8217;s the result:</p>
<div id="attachment_572" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/8.png"><img class="size-medium wp-image-572" title="address" src="http://www.davepcguy.com/wp-content/uploads/2009/10/8-300x211.png" alt="address" width="300" height="211" /></a><p class="wp-caption-text">address</p></div>
<p>Also, note that I don&#8217;t remember the address nor the phone number of the business, and I&#8217;ll have to change that later. Now to the right, I propose I add that &#8220;purpose text&#8221; I was talking about. As you can see so far, I don&#8217;t want to add any color nor any special effects. I might later on, but not at the moment, it makes it easier this way. It&#8217;s far too hard to describe where I placed the text so just check the picture below.</p>
<div id="attachment_573" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/9.png"><img class="size-medium wp-image-573" title="purpose text" src="http://www.davepcguy.com/wp-content/uploads/2009/10/9-300x184.png" alt="purpose text" width="300" height="184" /></a><p class="wp-caption-text">purpose text</p></div>
<p>It&#8217;s done with a 40pt font, Myria Pro, center-aligned. Now let&#8217;s add some &#8220;fun&#8221; to the coupon because now all it is is just text and a circle that will become a logo later on. Go to a <a href="http://www.terryburton.co.uk/barcodewriter/generator/">barcode generator</a>. Use any barcode mode you wish to, I used the default and its default settings. Click generate, and open the picture below in PNG (click on PNG right above the barcode), transfer the picture into Illustrator. Next, stretch and shrink it, making it non-usable but still just as much fun, and put it under the purpose-text. Here&#8217;s what I got:</p>
<div id="attachment_574" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/10.png"><img class="size-medium wp-image-574" title="barcode" src="http://www.davepcguy.com/wp-content/uploads/2009/10/10-300x148.png" alt="barcode" width="300" height="148" /></a><p class="wp-caption-text">barcode</p></div>
<p>And here&#8217;s my final result:</p>
<p style="text-align: center;">
<div id="attachment_575" class="wp-caption aligncenter" style="width: 551px"><a href="http://www.davepcguy.com/wp-content/uploads/2009/10/final.png"><img class="size-full wp-image-575 " title="final" src="http://www.davepcguy.com/wp-content/uploads/2009/10/final.png" alt="final" width="541" height="362" /></a><p class="wp-caption-text">final</p></div>
<p>That&#8217;s it though, save the picture as a .png file and upload it to your website. In my next tutorial, I&#8217;ll cover how to add custom names through some PHP and CSS knowledge. Don&#8217;t forget to erase the textbox and the name from the coupon. (ie Alexander, the line below it, and the box around it) We&#8217;ll add all that with CSS later.<br />
I hope you enjoyed my tutorial!<br />
</p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;partner=sociable" title="Print"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;title=Coupon%20design%20&amp;bodytext=Remember%20a%20couple%20weeks%20ago%20I%20mentioned%20I%20would%20be%20making%20a%20website%20for%20a%20chiropractor%3F%20Well%2C%20here%20it%20is.%20I%20finally%20got%20my%20client%20to%20approve%20the%20hosting%20and%20the%20domain.%20I%27m%20using%20JustHost%20for%20the%20hosting%20and%20I%20installed%20a%20preliminary%20wordpress%20templa" title="Digg"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;title=Coupon%20design%20&amp;notes=Remember%20a%20couple%20weeks%20ago%20I%20mentioned%20I%20would%20be%20making%20a%20website%20for%20a%20chiropractor%3F%20Well%2C%20here%20it%20is.%20I%20finally%20got%20my%20client%20to%20approve%20the%20hosting%20and%20the%20domain.%20I%27m%20using%20JustHost%20for%20the%20hosting%20and%20I%20installed%20a%20preliminary%20wordpress%20templa" title="del.icio.us"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;t=Coupon%20design%20" title="Facebook"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;title=Coupon%20design%20&amp;annotation=Remember%20a%20couple%20weeks%20ago%20I%20mentioned%20I%20would%20be%20making%20a%20website%20for%20a%20chiropractor%3F%20Well%2C%20here%20it%20is.%20I%20finally%20got%20my%20client%20to%20approve%20the%20hosting%20and%20the%20domain.%20I%27m%20using%20JustHost%20for%20the%20hosting%20and%20I%20installed%20a%20preliminary%20wordpress%20templa" title="Google Bookmarks"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;title=Coupon%20design%20&amp;source=Dave+PC+Guy+Computers+and+Technology&amp;summary=Remember%20a%20couple%20weeks%20ago%20I%20mentioned%20I%20would%20be%20making%20a%20website%20for%20a%20chiropractor%3F%20Well%2C%20here%20it%20is.%20I%20finally%20got%20my%20client%20to%20approve%20the%20hosting%20and%20the%20domain.%20I%27m%20using%20JustHost%20for%20the%20hosting%20and%20I%20installed%20a%20preliminary%20wordpress%20templa" title="LinkedIn"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;title=Coupon%20design%20" title="Reddit"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;t=Coupon%20design%20&amp;s=Remember%20a%20couple%20weeks%20ago%20I%20mentioned%20I%20would%20be%20making%20a%20website%20for%20a%20chiropractor%3F%20Well%2C%20here%20it%20is.%20I%20finally%20got%20my%20client%20to%20approve%20the%20hosting%20and%20the%20domain.%20I%27m%20using%20JustHost%20for%20the%20hosting%20and%20I%20installed%20a%20preliminary%20wordpress%20templa" title="Tumblr"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Coupon%20design%20%20-%20http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F" title="Twitter"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Coupon%20design%20&amp;body=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F" title="email"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Coupon%20design%20&amp;url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F" title="Slashdot"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.davepcguy.com%2Farchive%2Fcoupon-design%2F&amp;title=Coupon%20design%20" title="StumbleUpon"><img src="http://www.davepcguy.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.davepcguy.com/archive/coupon-design/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

