PHP easy font color question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mbatestblrock
    New Member
    • Sep 2007
    • 164

    PHP easy font color question

    Okay, I know this probably going to be flat out the dumbest question anyone has seen on here, and I apologize for this.

    I am using a sendmail.php script and it works just fine but for some reason I cannot figure out how to color the inputs from the form in red.. or any color for that matter. I assume this is easily done, I was just trying to use <font color=********> $q1 </font>


    here is my script I am trying to get all the form responses in red.


    Code:
    <?
      $q1 = $_REQUEST['q1'] ;
      $q2 = $_REQUEST{'q2'} ;
      $q3 = $_REQUEST{'q3'} ;
      $q4 = $_REQUEST['q4'] ;
      $q5 = $_REQUEST['q5'] ;
      $q6 = $_REQUEST['q6'] ;
      $q7 = $_REQUEST['q7'] ;
      $q8 = $_REQUEST['q8'] ;
      $q9 = $_REQUEST['q9'] ;
      $q10 = $_REQUEST['q10'] ;
      $comments = $_REQUEST['comments'] ;
      
      if (!isset($_REQUEST['q1'])) {
        header( "Location: http://itsurvey.tblrock.com" );
      }
      elseif (empty($q1) || empty($q2) || empty($q3) || empty($q4) || empty($q5) || empty($q6) || empty($q7) || empty($q8) || empty($q9) || empty($q10)) {
        ?>
    
        <html>
        <head><title>Error</title></head>
        <body>
        <h1>Error</h1>
        <p>
        All of the questions must be answered before submitting your survey.  Please press your browsers back button and make sure all of them are filled in.
        </p>
        </body>
        </html>
    
        <?php
      }
      else {
      
    
      mail( "feedback@email.com", "Survey Response",
    "The overall quality of phone support: \n$q1\n\nThe overall quality of Email support: \n$q2\n\nThe overall quality of on-site support: \n$q3\n\nThe IT department responds in a timely manner: \n$q4\n\nI feel the IT Department is knowledgeable and professional: \n$q5\n\nI feel the IT Department cares about my issues: \n$q6\n\nThe IT staff understands my needs: \n$q7\n\nThe IT staff has been courteous and helpful: \n$q8\n\nThe IT staff provides complete, accurate information to me: \n$q9\n\nOverall my experiences with the IT department have been positive: \n$q10\n\nComments: \n$comments",
    	"From: feedback@email.com" );
      header( "Location: thankyou.html" );
      }
    ?>

    Thank you for any responses!
  • stepterr
    New Member
    • Nov 2007
    • 157

    #2
    Originally posted by mbatestblrock
    Okay, I know this probably going to be flat out the dumbest question anyone has seen on here, and I apologize for this.

    I am using a sendmail.php script and it works just fine but for some reason I cannot figure out how to color the inputs from the form in red.. or any color for that matter. I assume this is easily done, I was just trying to use <font color=********> $q1 </font>


    here is my script I am trying to get all the form responses in red.


    Code:
    <?
      $q1 = $_REQUEST['q1'] ;
      $q2 = $_REQUEST{'q2'} ;
      $q3 = $_REQUEST{'q3'} ;
      $q4 = $_REQUEST['q4'] ;
      $q5 = $_REQUEST['q5'] ;
      $q6 = $_REQUEST['q6'] ;
      $q7 = $_REQUEST['q7'] ;
      $q8 = $_REQUEST['q8'] ;
      $q9 = $_REQUEST['q9'] ;
      $q10 = $_REQUEST['q10'] ;
      $comments = $_REQUEST['comments'] ;
      
      if (!isset($_REQUEST['q1'])) {
        header( "Location: http://itsurvey.tblrock.com" );
      }
      elseif (empty($q1) || empty($q2) || empty($q3) || empty($q4) || empty($q5) || empty($q6) || empty($q7) || empty($q8) || empty($q9) || empty($q10)) {
        ?>
    
        <html>
        <head><title>Error</title></head>
        <body>
        <h1>Error</h1>
        <p>
        All of the questions must be answered before submitting your survey.  Please press your browsers back button and make sure all of them are filled in.
        </p>
        </body>
        </html>
    
        <?php
      }
      else {
      
    
      mail( "feedback@email.com", "Survey Response",
    "The overall quality of phone support: \n$q1\n\nThe overall quality of Email support: \n$q2\n\nThe overall quality of on-site support: \n$q3\n\nThe IT department responds in a timely manner: \n$q4\n\nI feel the IT Department is knowledgeable and professional: \n$q5\n\nI feel the IT Department cares about my issues: \n$q6\n\nThe IT staff understands my needs: \n$q7\n\nThe IT staff has been courteous and helpful: \n$q8\n\nThe IT staff provides complete, accurate information to me: \n$q9\n\nOverall my experiences with the IT department have been positive: \n$q10\n\nComments: \n$comments",
    	"From: feedback@email.com" );
      header( "Location: thankyou.html" );
      }
    ?>

    Thank you for any responses!
    This is what I do for my message parameter when using the mail function. Then you can use the HTML tags to do anything with the way it is displayed in the email.
    [PHP]$message ="<table><tr><t d><b>Heading</b></td></tr>";
    $message .="<tr><td><b>N ame:</b> " . $_POST['name'] . "</td></tr> ";
    $message .="<tr><td><b>P hone:</b> " . $_POST['phone'] . "</td></tr> ";
    $message .="<table>";[/PHP]

    another benefit is then my call to the mail function is nice and clean.
    [PHP]$mail = mail($to, $subject, $message, $headers);[/PHP]

    Give that a try and let me know if you have any questions.

    Comment

    • mbatestblrock
      New Member
      • Sep 2007
      • 164

      #3
      Originally posted by stepterr
      This is what I do for my message parameter when using the mail function. Then you can use the HTML tags to do anything with the way it is displayed in the email.
      [PHP]$message ="<table><tr><t d><b>Heading</b></td></tr>";
      $message .="<tr><td><b>N ame:</b> " . $_POST['name'] . "</td></tr> ";
      $message .="<tr><td><b>P hone:</b> " . $_POST['phone'] . "</td></tr> ";
      $message .="<table>";[/PHP]

      another benefit is then my call to the mail function is nice and clean.
      [PHP]$mail = mail($to, $subject, $message, $headers);[/PHP]

      Give that a try and let me know if you have any questions.
      Hey that IS a great idea, I will be giving this a shot when I get to my work computer in the AM. Thanks a ton... will update tomorrow!

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        for emails to be formatted in HTML you have to send the right headers
        [php]
        $headers = "MIME-Version: 1.0\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1";
        [/php]
        Something like that... i think.

        Comment

        • stepterr
          New Member
          • Nov 2007
          • 157

          #5
          Originally posted by markusn00b
          for emails to be formatted in HTML you have to send the right headers
          [php]
          $headers = "MIME-Version: 1.0\n";
          $headers .= "Content-type: text/html; charset=iso-8859-1";
          [/php]
          Something like that... i think.
          Markusn00b, thanks for adding that, you are right! You don't have to have the first line, but definitely the second. This is how I have my headers setup.

          [PHP]$headers = "From: $from\r\n";
          $headers .= "Content-type: text/html\r\n";[/PHP]

          Comment

          • mbatestblrock
            New Member
            • Sep 2007
            • 164

            #6
            Originally posted by markusn00b
            for emails to be formatted in HTML you have to send the right headers
            [php]
            $headers = "MIME-Version: 1.0\n";
            $headers .= "Content-type: text/html; charset=iso-8859-1";
            [/php]
            Something like that... i think.

            Okay I am trying this out now, and when I try the first idea. I get

            Parse error: syntax error, unexpected T_STRING in H:\share\IT\Web sites\IT_Survey \counter\sendma il.php on line 2


            I am trying to read up on the header business right now. any help is more than welcome!

            thank you guys!

            Comment

            • stepterr
              New Member
              • Nov 2007
              • 157

              #7
              Originally posted by mbatestblrock
              Okay I am trying this out now, and when I try the first idea. I get

              Parse error: syntax error, unexpected T_STRING in H:\share\IT\Web sites\IT_Survey \counter\sendma il.php on line 2


              I am trying to read up on the header business right now. any help is more than welcome!

              thank you guys!
              That usually means you are missing a " ; " or something along those lines. And it might be line 1 that is actually causing the error.

              Comment

              • mbatestblrock
                New Member
                • Sep 2007
                • 164

                #8
                Originally posted by stepterr
                Markusn00b, thanks for adding that, you are right! You don't have to have the first line, but definitely the second. This is how I have my headers setup.

                [PHP]$headers = "From: $from\r\n";
                $headers .= "Content-type: text/html\r\n";[/PHP]

                So I have to say I am such a novice with PHP it is hardly funny. I tried reading up on the headers that you guys wrote about so I didnt seem like TOO much of a jerk, but I got to say I cant find squat that doesnt confuse me. I think its just a simple problem and I am reading far too complex of forums, etc.

                Here is my code and what is my attempt at putting the headers .= "content... .

                as you can see the only thing that has a font tag on it is q1 at the very top. Once I figure just one out Ill be good.

                If someone could help me out I would be forever in their debt!

                Thank you!

                Code:
                <?
                  $q1 = <font color="red">$_REQUEST['q1']</font> ;
                  $q2 = $_REQUEST{'q2'} ;
                  $q3 = $_REQUEST{'q3'} ;
                  $q4 = $_REQUEST['q4'] ;
                  $q5 = $_REQUEST['q5'] ;
                  $q6 = $_REQUEST['q6'] ;
                  $q7 = $_REQUEST['q7'] ;
                  $q8 = $_REQUEST['q8'] ;
                  $q9 = $_REQUEST['q9'] ;
                  $q10 = $_REQUEST['q10'] ;
                  $comments = $_REQUEST['comments'] ;
                  $Formid = $_REQUEST['Formid'] ;
                  $headers .= "Content-type: text/html\r\n";
                  
                  if (!isset($_REQUEST['q1'])) {
                    header( "Location: http://website.com" );
                  }
                  elseif (empty($q1) || empty($q2) || empty($q3) || empty($q4) || empty($q5) || empty($q6) || empty($q7) || empty($q8) || empty($q9) || empty($q10)) {
                    ?>
                
                    <html>
                    <head><title>Error</title></head>
                    <body>
                    <h1>Error</h1>
                    <p>
                    All of the questions must be answered before submitting your survey.  Please press your browsers back button and make sure all of them are filled in.
                    </p>
                    </body>
                    </html>
                
                    <?
                  }
                  else {
                  
                
                  mail( "feedback@tblrock.com", "IT Department Survey Response",
                "$Formid\n\nThe overall quality of phone support: \n$q1\n\nThe overall quality of Email support: \n$q2\n\nThe overall quality of on-site support: \n$q3\n\nThe IT department responds in a timely manner: \n$q4\n\nI feel the IT Department is knowledgeable and professional: \n$q5\n\nI feel the IT Department cares about my issues: \n$q6\n\nThe IT staff understands my needs: \n$q7\n\nThe IT staff has been courteous and helpful: \n$q8\n\nThe IT staff provides complete, accurate information to me: \n$q9\n\nOverall my experiences with the IT department have been positive: \n$q10\n\nComments: \n$comments",
                	"From: feedback@website.com");
                  header( "Location: thankyou.html" );
                  
                  }
                ?>

                Comment

                • stepterr
                  New Member
                  • Nov 2007
                  • 157

                  #9
                  mbatestblrock, Take a look at this stripped down example
                  [PHP]<?php
                  $to = $_POST["toEmail"];
                  $from = $our_email;
                  $subject = $_POST["subject"];
                  $message ="<table><tr><t d><b>Website Design Inquiry</b></td></tr>";
                  $message .="<tr><td><b>N ame: </b> " . $_POST['name'] . "</td></tr> ";
                  $message .="<tr><td><b>P hone:</b> " . $_POST['phone'] . "</td></tr> ";
                  $message .="<tr><td><b>E mail:</b> " . $_POST['email'] . "</td></tr> ";
                  $message .="<tr><td><b>M essage:</b> <br>" . $_POST['message'] . "</td></tr></table>";
                  // Additional headers
                  $headers = "From: $from\r\n";
                  $headers .= "Content-type: text/html\r\n";
                  $mail = mail($to, $subject, $message, $headers);
                  if($mail)
                  {
                  // Message sent sucessfully, do some code
                  }
                  else
                  {
                  //Message errored, do some code
                  }

                  ?>[/PHP]

                  Now say I wanted the "Name" Field label to show up in red, I would do the following on that line.

                  [PHP]$message .="<tr><td><b>< p style='color:#F F0000'>Name: </b></p> " . $_POST['name'] . "</td></tr> ";[/PHP]


                  Hopefully seeing a full example will help you out. Let me know if you have any other questions. Also, I noticed that around your q2 and q3 fields you have curly brackets"{ }" instead of "[ ]", don't forget to correct those too! :-)

                  Comment

                  • mbatestblrock
                    New Member
                    • Sep 2007
                    • 164

                    #10
                    Originally posted by stepterr
                    mbatestblrock, Take a look at this stripped down example
                    [PHP]<?php
                    $to = $_POST["toEmail"];
                    $from = $our_email;
                    $subject = $_POST["subject"];
                    $message ="<table><tr><t d><b>Website Design Inquiry</b></td></tr>";
                    $message .="<tr><td><b>N ame: </b> " . $_POST['name'] . "</td></tr> ";
                    $message .="<tr><td><b>P hone:</b> " . $_POST['phone'] . "</td></tr> ";
                    $message .="<tr><td><b>E mail:</b> " . $_POST['email'] . "</td></tr> ";
                    $message .="<tr><td><b>M essage:</b> <br>" . $_POST['message'] . "</td></tr></table>";
                    // Additional headers
                    $headers = "From: $from\r\n";
                    $headers .= "Content-type: text/html\r\n";
                    $mail = mail($to, $subject, $message, $headers);
                    if($mail)
                    {
                    // Message sent sucessfully, do some code
                    }
                    else
                    {
                    //Message errored, do some code
                    }

                    ?>[/PHP]

                    Now say I wanted the "Name" Field label to show up in red, I would do the following on that line.

                    [PHP]$message .="<tr><td><b>< p style='color:#F F0000'>Name: </b></p> " . $_POST['name'] . "</td></tr> ";[/PHP]


                    Hopefully seeing a full example will help you out. Let me know if you have any other questions. Also, I noticed that around your q2 and q3 fields you have curly brackets"{ }" instead of "[ ]", don't forget to correct those too! :-)
                    haha thanks for the curly notice! So what if you wanted the Name variable to be red instead of the label? I assume its the same process then?

                    Comment

                    • Markus
                      Recognized Expert Expert
                      • Jun 2007
                      • 6092

                      #11
                      Originally posted by mbatestblrock
                      haha thanks for the curly notice! So what if you wanted the Name variable to be red instead of the label? I assume its the same process then?
                      Yep!

                      Just wrap the
                      [php]
                      ".$_POST['name']."
                      [/php]
                      With
                      [code=html]
                      <p style="...">$na me</p>
                      [/code]
                      :)

                      Comment

                      • stepterr
                        New Member
                        • Nov 2007
                        • 157

                        #12
                        Originally posted by mbatestblrock
                        haha thanks for the curly notice! So what if you wanted the Name variable to be red instead of the label? I assume its the same process then?

                        No problem! I know how much time can be wasted on little typos like that and how annoying it can be.

                        Yep, if I wanted the variable itself to be red then I would just put the "P" tag around the variable instead of the label like this:

                        [PHP]$message .="<tr><td><b>N ame: </b><p style='color:#F F0000'> " . $_POST['name'] . "</p></td></tr> ";[/PHP]

                        Comment

                        • Markus
                          Recognized Expert Expert
                          • Jun 2007
                          • 6092

                          #13
                          Originally posted by stepterr
                          No problem! I know how much time can be wasted on little typos like that and how annoying it can be.

                          Yep, if I wanted the variable itself to be red then I would just put the "P" tag around the variable instead of the label like this:

                          [PHP]$message .="<tr><td><b>N ame: </b><p style='color:#F F0000'> " . $_POST['name'] . "</p></td></tr> ";[/PHP]
                          Sorry for stealing your thunder

                          :(

                          I get bored around here, so feel the need to but in on others...

                          I'm a terrible person, i know.

                          Comment

                          • stepterr
                            New Member
                            • Nov 2007
                            • 157

                            #14
                            Originally posted by markusn00b
                            Sorry for stealing your thunder

                            :(

                            I get bored around here, so feel the need to but in on others...

                            I'm a terrible person, i know.
                            :-) No problem Markusn00b! I'm all for someone getting answers to their questions as quickly as possible no matter where the answer comes from! Besides, it looks like we were posting at the exact same time, I happen to be having a pretty slow day as well.

                            Comment

                            • Markus
                              Recognized Expert Expert
                              • Jun 2007
                              • 6092

                              #15
                              Haha! Bang on the same time!

                              What are the chances?

                              If only there were more not-so php inclined people around, i wouldn't be so bored and i also wouldn't have to watch seasons 1-6 of scrubs :(

                              Comment

                              Working...