Avatar of Sirocco

asked on 

Formatting feedback form

The feedback form I use send email in text format; problem is that mail message is not formatted/aligned, so it looks not too accurate in email.

Name: Jonatan
email: sample@yahoo.com
phone: 123456789
comments: text text text

I would like to add a simple formatting, to make it look more accurate.
if (!$_POST){
	$return_from_module = draw_forma();
} else {
	$error = check_data();
	if ($error){
        $return_from_module = draw_forma($error,$_POST);
	} else {
        $return_from_module = draw_success();
function draw_success(){
$body ="";
foreach($_POST as $field=>$value)
        if($field!="submit")    $body .="$field: $value\r\n";
if(mail ("info@website.com",'from WEBsite sample.com',$body,"From:website"))
return 'Thank You!';
function check_data(){
	$error = '';
	$error_mark = 'style="color:red"';
	if (!$_POST["comments"])$error['comments'] = $error_mark;
    if (!isset($_POST["email"]) OR (!preg_match('/\b(?:mailto:)?([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,7})\b/i', $_POST["email"]))) { $error['email'] = $error_mark; }
	if (!$_POST["Name"]) $error['Name'] = $error_mark;
	if (!$_POST["phone"]) $error['phone'] = $error_mark;
	return $error;
function draw_forma($error=null,$POST=null){
	<form method=post action="">
    	#form-table TD {vertical-align:top;padding-top:5px}
    	.zvezda {color:red}
	<table cellspacing=0 border="0">
		<td  valign=top>
    <table border=0 id=form-table>
	        <td '.@$error["Name"].'>#ins:message:name:vards#<span class=zvezda>*</span></td>
			<td><input type="text" class=input value="'.$POST["Name"].'" name="Name" size=35></td>
	        <td '.@$error["email"].'>#ins:message:name:email#<span class=zvezda>*</span></td>
			<td><input type="text" class=input value="'.$POST["email"].'" name="email" size=35></td>
	        <td '.@$error["phone"].'>#ins:message:name:phone#<span class=zvezda>*</span></td>
			<td><input type="text" class=input value="'.$POST["phone"].'" name="phone" size=35></td>
	        <td '.@$error["comments"].'>#ins:message:name:Enquiry#<span class=zvezda>*</span></td>
			<td><textarea name="comments" cols=42 rows=5>'.$POST["comments"].'</textarea></td>
		<td valign=top align=center>
	        <input type="submit" value=" Send form " name="submit">
	return $html;

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon