email layout question

Hi guys new to doing php coding & been working on this project for a few days. It’s sending me emails & working but id like some advice on a few fine tuning points.

I’d like to add my logo to the email & I’m not sure where to add it so in the email its at the top of the page.
I’ve been reading many different scripts & none seem to work for me?

2nd thing is I’d like to change the colour & bold of the text in the email & the layout.
The idea behind this form is it’s an official entry form & needs to be set out in a certain way.

3rd thing is I need to add signature areas towards the bottom of the form to be signed on race day

this is my file so far

<?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "[email protected]"; $email_subject = "Online Entry Form"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.

"; echo $error."

"; echo "Please go back and fix these errors.

"; die(); } // validation expected data exists if(!isset($_POST['owners_name']) || !isset($_POST['club'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $owners_name = $_POST['owners_name']; // required $bo_licence_no = $_POST['bo_licence_no']; // not required $apba_log_number = $_POST['apba_log_number']; // not required $club = $_POST['club']; // not required $email_from = $_POST['email']; // not required $telephone = $_POST['telephone']; // not required $address = $_POST['address']; // not required $city = $_POST['city']; // not required $post_code = $_POST['post_code']; // not required $country = $_POST['country']; // not required $name_of_boat = $_POST['name_of_boat']; // not required $race_number = $_POST['race_number']; // not required $sba_reg_number = $_POST['sba_reg_number']; // not required $expiry_date = $_POST['expiry_date']; // not required $class_of_boat = $_POST['class_of_boat']; // not required $cc = $_POST['cc']; // not required $motor_make = $_POST['motor_make']; // not required $cc = $_POST['cc']; // not required $injected_or_blown = $_POST['injected_or_blown']; // not required $length = $_POST['length']; // not required $beam = $_POST['beam']; // not required $depth = $_POST['depth']; // not required $driver_name = $_POST['driver_name']; // not required $driver_club = $_POST['driver_club']; // not required $driver_apba_licence = $_POST['driver_apba_licence']; // not required $driver_licence = $_POST['driver_licence']; // not required $driver_expiry = $_POST['driver_expiry']; // not required $driver_mobile = $_POST['driver_mobile']; // not required $driver_email = $_POST['driver_email']; // not required $driver_address = $_POST['driver_address']; // not required $driver_city = $_POST['driver_city']; // not required $driver_country = $_POST['driver_country']; // not required $owner_dec = $_POST['owner_dec']; // not required $driver_dec = $_POST['driver_dec']; // not required $error_message = ""; $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$owners_name)) { $error_message .= 'The Owners Name you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$bo_licence_no)) { $error_message .= 'The Boat Owners Number you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$apba_log_number)) { $error_message .= 'The Boat Owners ABPA Log Book Number you entered does not appear to be valid.
'; } $string_exp = "/^[0-9- A-Za-z .'-]+$/"; if(!preg_match($string_exp,$club)) { $error_message .= 'The Owners Club you entered does not appear to be valid.
'; } $string_exp = "/^[0-9]+$/i"; // 555- 555- 5555 if(!preg_match($string_exp,$telephone)) { $error_message .= 'The Owners Phone number you entered does not appear to be valid.
'; }$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.
'; }$string_exp = "/^[0-9- A-Za-z .'-]+$/"; if(!preg_match($string_exp,$address)) { $error_message .= 'The Address you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$city)) { $error_message .= 'The City you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$country)) { $error_message .= 'The Owners Country you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$name_of_boat)) { $error_message .= 'The Name of the Boat you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$name_of_boat)) { $error_message .= 'The Name of the Boat you entered does not appear to be valid.
'; } $string_exp = "/^[0-9-A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$race_number)) { $error_message .= 'The Race number of the boat you entered does not appear to be valid.
'; } $string_exp = "/^[0-9]{2}-[0-9]{2}-[0-9]{4}$/i"; // 55- 55- 5555 if(!preg_match($string_exp,$expiry_date)) { $error_message .= 'The boat expiry date you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$class_of_boat)) { $error_message .= 'The Class of boat you entered does not appear to be valid.
'; } $string_exp = "/^[0-9-A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$motor_make)) { $error_message .= 'The Motor make of the boat you entered does not appear to be valid.
'; } $string_exp = "/^[0-9-A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$cc)) { $error_message .= 'The Engine Capacity(CC) of the boat you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$injected_or_blown)) { $error_message .= 'The Induction Type of the boat you entered does not appear to be valid.
'; } $string_exp = "/^[0-9-A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$length)) { $error_message .= 'The Length of Boat (in meters) you entered does not appear to be valid.
'; } $string_exp = "/^[0-9-A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$beam)) { $error_message .= 'The Beam of Boat (in meters) you entered does not appear to be valid.
'; } $string_exp = "/^[0-9-A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$depth)) { $error_message .= 'The Depth of Boat (in meters) you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$driver_name)) { $error_message .= 'The Drivers Name you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$driver_club)) { $error_message .= 'The Drivers Club you entered does not appear to be valid.
'; } $string_exp = "/^[0-9-A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$driver_apba_licence)) { $error_message .= 'The Drivers APBA Licence Number you entered does not appear to be valid.
'; } $string_exp = "/^[0-9-A-Za-z0-9- .'-]+$/"; if(!preg_match($string_exp,$sba_reg_number)) { $error_message .= 'The Drivers SBA Licence Number you entered does not appear to be valid.
'; } $string_exp = "/^[0-9]{2}-[0-9]{2}-[0-9]{4}$/i"; // 55- 55- 5555 if(!preg_match($string_exp,$driver_expiry)) { $error_message .= 'The Drivers expiry date you entered does not appear to be valid.
'; } $string_exp = "/^[0-9]+$/i"; if(!preg_match($string_exp,$driver_mobile)) { $error_message .= 'The Drivers Mobile Number you entered does not appear to be valid.
'; } $string_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($string_exp,$driver_email)) { $error_message .= 'The Drivers Email Address you entered does not appear to be valid.
'; } $string_exp = "/^[0-9- A-Za-z .'-]+$/"; if(!preg_match($string_exp,$driver_address)) { $error_message .= 'The Drivers Address you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$driver_city)) { $error_message .= 'The Drivers City you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$driver_country)) { $error_message .= 'The Drivers Country you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$owner_dec)) { $error_message .= 'The Declaration of the Owner you entered does not appear to be valid.
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$driver_dec)) { $error_message .= 'The Declaration of the Driver you entered does not appear to be valid.
'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Owners Name: ".clean_string($owners_name)."\n"; $email_message .= "B/O Licence NO: ".clean_string($bo_licence_no)."\n"; $email_message .= "Club: ".clean_string($club)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Street Address: ".clean_string($address)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "Post Code: ".clean_string($post_code)."\n"; $email_message .= "Country: ".clean_string($country)."\n\n"; $email_message .= "Name of Boat: ".clean_string($name_of_boat)."\n"; $email_message .= "Race Number: ".clean_string($race_number)."\n"; $email_message .= "SBA Reg Number: ".clean_string($sba_reg_number)."\n"; $email_message .= "SBA Expiry Date: ".clean_string($expiry_date)."\n"; $email_message .= "Class Entered: ".clean_string($class_of_boat)."\n"; $email_message .= "Additional Class Entered: ".clean_string($class_of_boat2)."\n"; $email_message .= "Motor Make & Model: ".clean_string($motor_make)."\n"; $email_message .= "Capacity (cc): ".clean_string($cc)."\n"; $email_message .= "Induction Type: ".clean_string($injected_or_blown)."\n"; $email_message .= "Length of Boat (in meters): ".clean_string($length)."\n"; $email_message .= "Beam: ".clean_string($beam)."\n"; $email_message .= "Depth: ".clean_string($depth)."\n"; $email_message .= "Does you boat have a cell? ".clean_string($Cell_Yes)."\n"; $email_message .= "Does you boat have a cell? ".clean_string($Cell_No)."\n"; $email_message .= "Cell Build Number: ".clean_string($cell_number)."\n"; $email_message .= "Drivers Name: ".clean_string($driver_name)."\n"; $email_message .= "Drivers Club: ".clean_string($driver_club)."\n"; $email_message .= "Drivers APBA Licence Number: ".clean_string($driver_apba_licence)."\n"; $email_message .= "SBA Driver Licence NO: ".clean_string($driver_licence)."\n"; $email_message .= "EXPIRY DATE: ".clean_string($driver_expiry)."\n"; $email_message .= "Drivers Club: ".clean_string($driver_club)."\n"; $email_message .= "Drivers Mobile Number: ".clean_string($driver_mobile)."\n"; $email_message .= "Drivers Email: ".clean_string($driver_email)."\n"; $email_message .= "Drivers Address: ".clean_string($driver_address)."\n"; $email_message .= "Drivers City: ".clean_string($driver_city)."\n"; $email_message .= "Drivers Post Code: ".clean_string($driver_post_code)."\n"; $email_message .= "Drivers Country: ".clean_string($driver_country)."\n"; $email_message .= "Drivers Name: ".clean_string($driver_name2)."\n"; $email_message .= "Drivers Club: ".clean_string($driver_club2)."\n"; $email_message .= "Drivers APBA Licence Number: ".clean_string($driver_apba_licence2)."\n"; $email_message .= "SBA Driver Licence NO: ".clean_string($driver_licence2)."\n"; $email_message .= "EXPIRY DATE: ".clean_string($driver_expiry2)."\n"; $email_message .= "Drivers Club: ".clean_string($driver_club2)."\n"; $email_message .= "Drivers Mobile Number: ".clean_string($driver_mobile2)."\n"; $email_message .= "Drivers Email: ".clean_string($driver_email2)."\n"; $email_message .= "Drivers Address: ".clean_string($driver_address2)."\n"; $email_message .= "Drivers City: ".clean_string($driver_city2)."\n"; $email_message .= "Drivers Post Code: ".clean_string($driver_post_code2)."\n"; $email_message .= "Drivers Country: ".clean_string($driver_country2)."\n"; $email_message .= "Owner Dec: ".clean_string($owner_dec)."\n"; $email_message .= "Driver Dec: ".clean_string($driver_dec)."\n"; $email_message .= "Safety Levy Payable: ".clean_string($safety_levy)."\n"; // create email headers $mail->Body = 'Embedded Image: PHPMailer Here is an image!'; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); $message = ""; $message .= ""; ?>

Thank you for you entry. We will shall be in touch with you very soon regarding payment.

<?php } ?>

Next time, please use the PHP tags and place all your code inside them. It makes our job easier to play with your code and allows us to get past it quickly as needed…

Well, number one, you should understand how emails work. We do not need to see all your email code to
explain how to do this. First, you can send emails as text emails or HTML emails. You appear to be sending
them as text emails. Therefore, you can not easily place a graphic into them. You can “print” them onto the
email using PHP’s header system and write an image into the email. This can get complicated. I have done
it in the past, but, is slow, ties up the server and hard to debug. If you wish to do it that way I will help with
the code. But, this means that every time you send out an email the server will have to write the picture
into the email as a “encoded-character” format. This adds to a lot of work for the server.

Now with all that said. You might wish to alter your emails into HTML format. This is fairly easy. You are
basically sending an HTML page. Why do I suggest this? Easy to do, able to add colors, backgrounds,
tables, links and just about anything you can place on a webpage. Once you have the basic layout set up,
it is easy to add in any graphic. (Such as your logo.) It is just a standard webpage tag. But, you
don’t send the picture. That is the trick. You leave the logo on your site and just put the link to it inside
your HTML page. If you change the the logo on the site, the next email sent out shows the new logo.

So, decide which way you would like to try it and we can help you with either one.

id like to convert it over to html & get it working.
I have a basic layout of what the form should look like but need to add in all the answers to the questions above

if you can help that would be awesome :slight_smile:

Well, first you need to see how to enter a webpage as data. You can actually create a webpage as an
email and just type it into your code. Then, that webpage becomes your base for the email and you
add in all your posted code where you want it. Since this is just a variable, you can insert data from
your fields by appending them inside the message.

It is really simple. The best way is to just create a webpage using whatever you use to do that with.
And, make it look exactly like you want the email to be. It can be simple or very creative. Just need to
know how to create a simple HTML page. Most anything will work. One note… CSS is best if you place
it inside each tag as needed. Not at the top of the page, but, inside each element.

Here is a simple sample that creates an email with two fields in place and a little formatting in place.
Should be enough to get you started…
[php]

<?PHP // Set up email and mail to one address for testing... // Grab data from the input fields on the form... $name = $_POST['name']; $address = $_POST['address']; // Just two fields for testing... Not yours I made this page up... // Email Subject $subject = 'Important message from Ernie...'; // Email Address $email = '[email protected]'; // Email Message $message = ' Welcome to our new website, ' . $name . ' !

We have your address as: ' . $address . '

'; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'To: ' . $email . '\r\n'; $headers .= 'From: Important Message the world of Ernie! ' . "\r\n"; // Mail it mail($email, $subject, $message, $headers); ?>

[/php]
You would have to alter the email addresses, fields, webpage layout and URL for the image to what you
have set up. This is just a small sampler to show you how to get started. In the ones I have in place in
one of my sites, it has full graphics, with fancy backgrounds, animated GIF’s, banners and lots eye candy.
Mine is 600 pixels wide which views on just about any device and includes fancy graphics, borders footers
and tons of tables. (Tables are nice because you can lay out everything easily… ) Good luck!

Hope this helps you to get started…

that’s great & i’m starting to understand how it all works.
if I was to get the logo to the top of the screen & then have the body of the email as all the fields I had in the last php I posted how would that work?
the layout of the email im after has been made on a html page but the questions I ask & fields the user enters needs to be in the email
it needs logos at the bottom like a formal letter accept I just don’t know how to lay it out
the original email is very plain & boring to look at
if I used the file_get_contents option I can import the html page I created but the answer fields are not filled in

Well, the email you already have created in HTML is HTML.
Just replace my short sample with your version. You will have to note the quotes and double-quotes
as they can break the copy. In my version, the outside quotes were single-quotes. Therefore,
to insert a PHP variable or fields variable, you need to end the page then use the . $somevariable . and
then restart with another single quote. Review my sampler and you will understand.

The variables are pulled from your posted fields. So the can be something like the ones I did or
you can just skip the variables and just use the posted values like . $_POST[‘first_name’] .

Hope that makes sense! It is easier than it looks.

Oh, and yes, you can get the file with get_contents, but, that is an HTML page. You would then have
to use a coding scheme like put <first_name> wherever you want the First Name to go and then inside
your PHP code after you file_get_contents, user STRING REPLACE function to replace them with the
posted values. In that way, you can create different email templates and use as needed…

the last part of your post is what im really interested in. It would have the full layout of the form im after including all breaks, logos etc in the email but setting up the coding for this is something id like to see.
the web page could be put into the email as seen on the website with all fields entered :slight_smile:
is there something like that in a script I can see anywhere?

Okay, you have an online form that let’s the users fill in all of the long list of data that is needed.

Now, that data should be saved into a database so that you have access to it for future use.
Once inside the database, on other pages, you can select out the lists of clubs or users and send
emails to them. An email can copy the info that was posted or it can pull data from the database.

So, one thing, emails are outgoing, not really incoming. So, you do not want to send out a form.
The email would be for info only. So, it would need the list of info pulled out of the form they submit
and just printed into the correct areas. Your current form is a little bit “form-like”. You might want to
redo it some. I will work on some ideas for that later…

What I do is save all of the data in the database and send out a simple email asking them to review
their data. They can log in and see their “profile” which will include areas for their boat(s), team
members, addresses, etc. They can update them as needed…

Now, back to your three original questions. The first two are solved with HTML emails. The 3rd is just
basically a minor change in how the email is set up. So how do you do that?

Use the base code that I gave you. But, create your HTML email as you want it first. Do not use any
fields in it. In all of the areas in the HTML where you want data pulled out and replaced, just use some
code words. For first names, use <First_Name>. For email address use <Email_Address> and etc…
Then, we can use the pulled values you posted at the beginning and replace these “tagged” items with
the live data. Does that make sense?

So, I will work up a new sampler based on what I sent before and what I have seen for your form page.
Give me some time to think out how to explain it all and how it will work. Are you saving the data into a
database?

not as yet, I haven’t written that part.
what you have seen is where I am up to… :frowning:
the data base I have an excel spread sheet with all details in it from the form.
I was going to email 3 different people once this goes ahead, save the information format for autofill so next time they use the form it will be quicker. This would need to be password protected.
Also save the information back to a new excel file to keep updated records

OUCH! LOL…

So, you have NOT really started as yet… Well, for this project, you need a lot of help.

I would be happy to help you. I will create a list for you and you can follow along.
But, again, most likely it will not be tonight or maybe tomorrow…

First, create a page that you would like to be the email you will send out. Just make it simple for now.
And, we will use that and combine it with your form page…

Also, there is a lot to handle for the database sections. I will walk you thru that too.
A lot of people on this site can help. But, most of it is fairly simple…

Problem has been solved & its now working to the way you posted in the comments :slight_smile:
thank you so much for your help its awesome

Sponsor our Newsletter | Privacy Policy | Terms of Service