Results 1 to 5 of 5

Thread: Really easy one: how to space form values in resulting email...

  1. #1
    Join Date
    Jan 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Really easy one: how to space form values in resulting email...

    I finally got my form working - just one more niggle - How do I get the different bits of info on separate lines?? This isn't working!

    PHP Code:
    function sendMail($name,$email,$phone,$message){
        
        
    $subject "Message from website";
        
    $from    "From: $name <$email>\r\nReply-To: $email\r\n"
        
    $header  "MIME-Version: 1.0\r\n"."Content-type: text/html; charset=iso-8859-1\r\n";
        
    $content "From: $name\r\n
        Contact Number: 
    $phone\r\n
        Enquiry: 
    $message\r\n";
        
        
        
    $content wordwrap($content,70);
        
    mail(MAIL_TARGET,$subject,$content,$from.$header); 

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try running it under the nl2br function.
    (The content of course)
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    lilibirdy (01-06-2009)

  4. #3
    Join Date
    Jan 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I didn't know you could use <br> How silly of me..... Thanks mate

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You can use <br>, bur say for example someone puts:
    Code:
    Hello
    My
    Name
    Is
    Nile
    If you were inserting it into a db or something, I think it would show up like this:
    Code:
    HelloMyNameIsNile
    Now if you used the nlbr function, it would show up like this:
    Code:
    Hello<br>
    My<br>
    Name<br>
    Is<br>
    Nile<br>
    Jeremy | jfein.net

  6. #5
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    If you want to avoid using html, you can do something like this:

    Code:
    		if ( empty($errors) ) {
    		
    			$to = "yourEmail";
    			$subject = "yourSubject";
    			$message = "From: $name\n\n";
    			$message .= "Email: $email\n\n";
    			$message .= "Message:\n\n";
    			$message .= wordwrap($textarea, 50, "\n");
    			$from = "From: <webmaster@yourwebsite.com>\n";
    		
    			if ( mail($to, $subject, $message, $from) ) {
    				$success = true;
    			} else {
    				$errors[] = '<p>Sorry, there is a problem sending the form.</p>';
    			}

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •