Skip to main content
Inspiring
November 26, 2012
Question

formatting php email form

  • November 26, 2012
  • 1 reply
  • 845 views

I have a working form that sends to a php page for processing. however there is a line of code that i dont understand. In the email the form us currently centred but i really need it aligned left.

below is one field and the alignment code

$fields{"field1"} = "text showing in email";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){           $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

can i delete the above code and put the $fields{"field1"} = "text showing in email"; into a table

thanks in advance

This topic has been closed for replies.

1 reply

BenPleysier
Community Expert
Community Expert
November 27, 2012

Please show all of the code of the php page

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Inspiring
November 27, 2012

<?php

$to = $_REQUEST['sendto'] ;

$from = $_REQUEST['email'] ;

$name = $_REQUEST['fullName'] ;

$headers = "From: $from";

$subject = "rent a property website application";

$fields = array();

$fields{"title"} = "Title";

$fields{"fullname"} = "Full Name";

$fields{"teleNumber"} = "Telephone Number";

$fields{"mobileNumber"} = "Mobile Number";

$fields{"email"} = "Email Address";

$fields{"contactMethod"} = "Preferred method of contact";

$fields{"currentAddress"} = "Current Address";

$fields{"rentLocation"} = "Where are you interested in renting";

$fields{"rentalAmount"} = "What is the maximum rental payment per month";

$fields{"propertyType"} = "What sort of property are you interested in";

$fields{"smoker"} = "Smoker";

$fields{"employmentStatus"} = "Employment status";

$fields{"numberOfPeople"} = "How many people will live in the property";

$fields{"numberOfChildren"} = "How many children";

$fields{"date"} = "Intended moving in date";

$fields{"month"} = "Intended moving in month";

$fields{"year"} = "Intended moving in year";

$fields{"funds"} = "Have you funds available";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){           $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: noreply@propsite.com";

$subject2 = "Thank you for contacting us";

$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.propsite.com";

if($from == '') {print "You have not entered an email, please go back and try again";}

else {

if($name == '') {print "You have not entered a name, please go back and try again";}

else {

$send = mail($to, $subject, $body, $headers);

$send2 = mail($from, $subject2, $autoreply, $headers2);

if($send)

{header( "Location: http://www.propsite.com/propsite/index.php" );}

else

{print "We encountered an error sending your mail, please notify webmaster@propsite.com"; }

}

}

?>