#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    70
    Rep Power
    2

    Align php email form


    Hello i have a php form script that works well but the output email makes all the content centred. i really need it aligned left. can anyone help please?

    this is what i have so far:

    PHP Code:
    <?php 
     $to 
    $_REQUEST['sendto'] ; 
     
    $from $_REQUEST['email'] ; 
     
    $name $_REQUEST['fullName'] ; 
     
    $headers "From: $from"
     
    $subject "website application"

     
    $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";

     
    $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@website.com"
     
    $subject2 "Thank you for contacting us"
     
    $autoreply "Thank you for contacting us. Somebody will get back to you as soon as possible.";
     
     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.website.com/index.php" );} 
     else 
     {print 
    "We encountered an error sending your mail, please notify webmaster@website.com"; } 
     }
    }
     
    ?>

    i thinks it has something to do with

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

    but i dont know where to start

    thanks in advance
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    read the documentation on printf(), especially the part on the alignment specifier.

IMN logo majestic logo threadwatch logo seochat tools logo