SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    uk
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can i format the way this php form code looks???

    hi,

    i have a form that returns the results on the same page but i want to format the way it looks. i'd like to add space or indent the lines of text that display and also make some bolder or perhaps change the colour.
    Anyone give me some pointers on how to do this?

    here's the code....

    PHP Code:
    <?
      
    }
    if (isset(
    $HTTP_POST_VARS["submit"]) and ($checked) ) {
      
    $msg "Your Message\n";
      
    $msg .= "Name :".$HTTP_POST_VARS["name"]."\n";
      
    $msg .= "Address :".$HTTP_POST_VARS["address"]."\n";
      
    $msg .= "Email :".$HTTP_POST_VARS["email"]."\n";
      
    $msg .= "Telephone :".$HTTP_POST_VARS["phone"]."\n";
      
    $msg .= "Town/city :".$HTTP_POST_VARS["town/city"]."\n";  
      
    $msg .= "County :".$HTTP_POST_VARS["county"]."\n";
      
    $msg .= "Postcode :".$HTTP_POST_VARS["postcode"]."\n";
      
    $msg .= "Comments :".$HTTP_POST_VARS["comments"]."\n";
      
    $headers "From: $HTTP_POST_VARS[email]"\r\n" ;
      
    mail("me@mywebsite.com","Enquiry from website",$msg$headers);
      echo 
    "       Thank you, your message has been sent to: <b>mywebsite.com</b></ br></ br>\n";
      echo 
    nl2br($msg) . "</ br>\r";
    }
    ?>
    thanks for any help,

    j

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    indenting can be done with spaces. but if you want to make something bold, you will need to send the email as html and then use html to format it.

    the manual provides the information you need to send an html email. look at the documentation for the mail() function.

  3. #3
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    uk
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    thanks for the quick response.
    Is there no simple way with the code that i've got to add spaces before the $msg = "Your Message\n"; ??

    It's just that it overlaps part of a graphic so i need all the lines to be moved to the right about 5 or 6 pixels..

    thanks

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    like i said, add some spaces

    $msg = " Your Message\n";

  5. #5
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    uk
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh right i see.

    well thanks again. i'll give it a go.

    cheers.

  6. #6
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    uk
    Posts
    240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    NO WORRIES I'VE GOT IT...HAD TO ADD &nbsp;
    THANKS AGAIN


    Hi,

    sorry that hasn't worked.
    i've added the spaces like this:
    $msg .= " Name :".$HTTP_POST_VARS["name"]."\n";

    could there be something wrong with the code?

    any ideas?

    thanks

  7. #7
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This line is ok, but this one
    PHP Code:
     $headers "From: $HTTP_POST_VARS[email]"\r\n" 
    is not. Your form can be easily abused to send out spam. See http://www.securephpwiki.com/index.php/Email_Injection

  8. #8
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you view the email you sent, multiple spaces are displayed because you sent the email as plain text.

    if you view the webpage, multiple spaces are not, because your webpage is html. html does not render multiple spaces.

    if you use &nbsp; then it will render correctly in html, but not in plain text.

    so no, you havent quite got it yet unless you dont care how the email looks.

  9. #9
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm


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
  •