目前的外觀將幾乎不具有組織,例如電子郵件:PHP Web表單;當表單提交它的造型外發電子郵件
Name:
JohnDoe
email:
[email protected]
message:
blah, blah, blah
我想在標籤左對齊,和值右對齊並在電子郵件中添加背景圖片。我知道我將需要使用表格;但我在PHP中絕不夠精通。看看代碼,我相信這條帶與外觀有關。我從html-form-guide.com獲得了表單。任何幫助將不勝感激,謝謝。
function FormSubmissionToMail()
{
$ret_str='';
foreach($_POST as $key=>$value)
{
if(!$this->IsInternalVariable($key))
{
$value = htmlentities($value,ENT_QUOTES,"UTF-8");
$value = nl2br($value);
$key = ucfirst($key);
$ret_str .= "<div class='label'>$key :</div><div class='value'>$value </div>\n";
}
}
foreach($this->fileupload_fields as $upload_field)
{
$field_name = $upload_field["name"];
if(!$this->IsFileUploaded($field_name))
{
continue;
}
$filename = basename($_FILES[$field_name]['name']);
$ret_str .= "<div class='label'>File upload '$field_name' :</div><div class='value'>$filename </div>\n";
}
return $ret_str;
}
function GetMailStyle()
{
$retstr = "\n<style>".
"body,.label, { font-family:Arial,Verdana; } ".
".label {font-weight:bold; margin-top:5px; font-size:1em; color:#000;} ".
".value {margin-bottom:15px;font-size:0.8em;padding-left:5px; font-family:Helvetica;} ".
"</style>\n";
return $retstr;
}
function GetHTMLHeaderPart()
{
$retstr = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'."\n".
'<html><head><title></title>'.
'<meta http-equiv=Content-Type content="text/html; charset=utf-8">';
$retstr .= $this->GetMailStyle();
$retstr .= '</head><body>';
return $retstr;
}
function GetHTMLFooterPart()
{
$retstr ='</body></html>';
return $retstr ;
}
function ComposeFormtoEmail()
{
$header = $this->GetHTMLHeaderPart();
$formsubmission = $this->FormSubmissionToMail();
$footer = $this->GetHTMLFooterPart();
$message = $header."Submission from 'contact us' form:<p>$formsubmission</p><hr/>".$footer;
return $message;
}
這令我更象是一個CSS/HTML的問題,而不是多用PHP做。 – 2013-02-22 16:54:59
html電子郵件!必須......抵抗......衝動......殺死...... – 2013-02-22 17:07:09