Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Setting Color using Array

the mail() function

Moderators: macek, egami, gesf

Setting Color using Array

Postby smcconnell » Mon Apr 14, 2014 7:11 am

Hello – someone here helped me with this some years ago and I've forgotten how, I'm not very knowledgable in this area. I have a form going to email. I want the responses be a color (in this case red) in the email. I have an array to make it work – and it does except that the email comes in with the font tags and my provider (netsolhost) looking like this:

From: <font style=color:red;>name@email.com </font@netsolhost.com>

Here's my php:

<?php

/* NAME ADDRESS EMAIL PHONE etc... */

$emailSubject = 'My Subject';
$webMaster = 'me@myemail.net';


/* GATHERING DATA VARIABLES */

$array = array('show_a','show_b','show_c','company','email','phone','address','city','state','zip','tax','buyer','buyer2','buyer3','buyer4','confirmed');
foreach($array as $post => $values) {
if (isset($_POST[$values])) {
$_POST[$values] = trim(strip_tags($_POST[$values]));
$_POST[$values] = '<font style="color:red;">'.$_POST[$values].'</font>';
}
}

$show_a = $_POST['show_a'];
$show_b = $_POST['show_b'];
$show_c = $_POST['show_c'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$tax = $_POST['tax'];
$buyer = $_POST['buyer'];
$buyer2 = $_POST['buyer2'];
$buyer3 = $_POST['buyer3'];
$buyer4 = $_POST['buyer4'];
$confirmed = $_POST['confirmed'];

$body = <<<EOD
<hr><br>
Show I Will Attend: $show <br>
Company Name: $company <br>
Email: $email <br>
Phone: $phone <br>
Address: $address <br>
City: $city <br>
State: $state <br>
Zip Code: $zip <br><br>
<hr><br>

Tax ID: $tax <br>
Buyer Name: $buyer <br>
Buyer two Name: $buyer2 <br>
Buyer three: $buyer3 <br>
Buyer four: $buyer4 <br>
Have I Read the Requirements: $confirmed <br>
<hr><br>

EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

/* RESULTS RENDERED AS HTML */

$theResults = <<<EOD
smcconnell
New php-forum User
New php-forum User
 
Posts: 11
Joined: Mon Mar 28, 2011 1:59 pm

Re: Setting Color using Array

Postby smcconnell » Mon Apr 14, 2014 7:49 am

I have solved my problem, or at least circumvented it.

I got rid of the array and assigned the font color to each item separately – except the email, which I left unstyled. Now there are no font tags or weirdness coming into the "From" part of the email and the answers come in red.
smcconnell
New php-forum User
New php-forum User
 
Posts: 11
Joined: Mon Mar 28, 2011 1:59 pm

Re: Setting Color using Array

Postby smcconnell » Mon Apr 14, 2014 7:50 am

Probably could have kept the array and removed email from it but what's done is done.
smcconnell
New php-forum User
New php-forum User
 
Posts: 11
Joined: Mon Mar 28, 2011 1:59 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.