I don't think this post should be posted here, but it's a contact form with php :)...

Anyways, I have a question about styling the email notifications you get after submitting a form.... I can't style it based off of my code... Can someone help me...?

This is my code... and apparently I can't style the emails...

CSS:

#stylized {
    position:absolute;
    z-index:1;
    left: 22px;
    top: 8px;
}
body{
font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
}
p, h1, form, button{border:0; margin:0; padding:0;}
.spacer{clear:both; height:1px;}
.myform{
margin:0 auto;
width:330px;
padding:14px;
height: 200px;
}
#stylized{
border:solid 1px #5c6063;
background: #EAEAEA;
}
#stylized h1 {
font-size:12px;
margin-bottom:8px;
}
#stylized label{
display:block;
text-align:left;
width:140px;
float:left;
left: 10px;
}
#stylized .small{
color:#666666;
display:block;
font-size:11px;
font-weight:normal;
text-align:right;
width:140px;
}
#stylized input{
float:left;
font-size:12px;
padding:4px 2px;
border:solid 1px #aacfe4;
width:200px;
margin:2px 0 20px -65px;
height: 20px;
}
#stylized button{
clear:both;
margin-left:150px;
width:125px;
height:31px;
background:#666666  no-repeat;
text-align:center;
line-height:31px;
color:#FFFFFF;
font-size:11px;
font-weight:bold;
}
.disclaimer {
    color: #CCC;
}
.disclaimer_dark {
    color: #666;
}

HTML:

<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="index.html">
<h1>Contact Us</h1>
<label>Name*</label>
<input type="text" name="name" id="name" />
<label> Email*</label>
<input type="text" name="email" id="email" />
<label>Comments
</label>
<input type="text" textarea name="comment" id="comment"></textarea>
<button type="submit">Contact Us</button>
<div class="spacer"></div>
</form>
</div>

PHP:

<?php
$to = '[michael21291024@gmail.com]';
//Clean data
$name = strip_tags(trim($_POST[name]));
$email = strip_tags(trim($_POST[email]));
$comment = strip_tags(trim($_POST[comment]));
////
$subject = "New form submitted";
$message = $name . "has submitted a form\n";
$message .= "Email address " . $email"\n";
$message .= "Comment: " . $comment;
mail($to,$subject,$message);
?>

Recommended Answers

All 2 Replies

So I know zero about PHP, but if you wanted to include styling in your email, couldn't you just include the HTML code as you build the message?

For example '$message = "<HTML tag>" . "text" . $var'

You can build an entire HTML page in this manner.

I am a bit aware of that, but I think I need some more explanations.... even though you say you know zero about PHP, you still know more than me :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.