Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: help with securing and retaining original styling

  1. #1
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    593
    Thanks
    43
    Thanked 28 Times in 28 Posts

    Default help with securing and retaining original styling

    of my feedback form.

    I made all of the additions in feedback2.txt

    This feedback form no long works as intended for me
    http://www.web-user.info/feedback/feedback1.txt (this is the original version)

    after the changes are made as you posted in the forum
    http://www.web-user.info/feedback/feedback2.txt (this is the secured form version)

    the first version has a nice html response I get back from each use of the form

    After I add your suggestions to tighten upsecurity I get a text email with all the html tags
    and everything as a regular text email

    Is there a way to have both-the secure form and also get the nicely styled question/answer
    form response

    Adrian was helping in a different thread here:
    http://www.dynamicdrive.com/forums/s...052#post296052

    I wanted to start a thread for just this before I get a warning-lol
    Last edited by ajfmrf; 06-15-2013 at 01:49 AM. Reason: fixed urls; my name was misspelled :)
    Thanks,

    Bud

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Here:
    PHP Code:
        $from "";
        
    $from .= "MIME-Version: 1.0" "\r\n";
        
    $from .= "Content-type: text/html; charset=iso-8859-1" "\r\n";
        
    $from "From: no-reply@web-user.net\r\nReply-to: $name <$email>\r\n"
    You write the MIME and Content-type headers, then you overwrite them with the From and Reply-to headers. On that last line, you need to concatenate ( .= ), not assign ( = ).

    (BTW, this is directly related to what we were working on in the other thread, so there's no need to worry about starting a new thread.
    Also, generally speaking, you have to be pretty dang far off-topic before you get a warning about it in your own thread .
    If you know it's unrelated, start a new thread; if it "might be" related (as in this case, where the issue cropped up right after changes you made), you're probably fine.)
    Last edited by traq; 06-11-2013 at 04:44 AM.

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

    ajfmrf (06-11-2013)

  4. #3
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    593
    Thanks
    43
    Thanked 28 Times in 28 Posts

    Default

    Okay I added that part for the mime and content to the headers and I am still getting the html file as it is written,not displayed as an html page(I get the whole thing with all html tags )

    http://www.web-user.info/feedback/feedback2.txt
    Thanks,

    Bud

  5. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by ajfmrf View Post
    Okay I added that part ...
    no, you didn't. from your linked code:
    PHP Code:
    <?php
    /* snip */
        
    $from .= "MIME-Version: 1.0" "\r\n";
        
    $from .= "Content-type: text/html; charset=iso-8859-1" "\r\n";
        
    $from "From: no-reply@web-user.net\r\nReply-to: $name <$email>\r\n";
    That's exactly as it was before: you write the MIME and Content-type headers, then overwrite them with the From and Reply-to headers. Read my post above again.

  6. #5
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    593
    Thanks
    43
    Thanked 28 Times in 28 Posts

    Default

    I guess you should color me dumb then-lol

    I don't understand what you mean by

    That's exactly as it was before: you write the MIME and Content-type headers, then overwrite them with the From and Reply-to headers. Read my post above again.
    I will go back to the first thread and back here to and see if I can figure out what you are saying?
    Thanks,

    Bud

  7. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    meaning you didn't make any changes to this part of your code:
    PHP Code:
    <?php
    /* snip */
        // at each step,                                                        // this is the value $from holds:
        
    $from .= "MIME-Version: 1.0" "\r\n";                                  //"MIME-Version: 1.0\r\n"
        
    $from .= "Content-type: text/html; charset=iso-8859-1" "\r\n";        //"MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"
        
    $from "From: no-reply@web-user.net\r\nReply-to: $name <$email>\r\n";  //"From: no-reply@web-user.net\r\nReply-to: $name <$email>\r\n"
    /* snip */
    As I described in post #2 above, on the last line of this snippet, you assign a new value to $from (using = ), where I would expect you to append to the current value (using .= ). That's why you're losing the Content-type headers, and your email is displaying as plain text.
    Last edited by traq; 06-15-2013 at 01:13 AM.

  8. #7
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    593
    Thanks
    43
    Thanked 28 Times in 28 Posts

    Default

    Okay,I think I understand what you maen but not knowing much about php I don't know how to do that.I am sorry but I am trying to learn as I go along here.

    I would try this from what you are saying.

    $from ="Content-Type:text/html; charset=iso-8859-1" . "\r\n" . ="Content-Type:text/html; charset=iso-8859-1" . "\r\n"

    ??? that uses both the 'equal' thing and asks for the same thing again?
    Thanks,

    Bud

  9. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    to address your current problem:

    in that last line ($from = "From: no-reply@web-user.net\r\nReply-to: $name <$email>\r\n";), don't use = . Use .= instead.


    more of an explanation...

    = is the assignment operator. It takes the value on the right side, and assigns it to the variable named on the left side:
    PHP Code:
    <?php

    $myVar 
    "hello";    // $myVar holds the value "hello"
    $myVar "goodbye";  // $myVar holds the value "goodbye"
    $myVar "";         // $myVar holds an empty string
    As you can see in the example above, = does not preserve any values that the variable had before the assignment. It overwrites any such values, and they are lost.

    . is the concatenation operator. It allows you to join two strings into one string:
    PHP Code:
    <?php

    $myVar 
    "hello" " " "goodbye";  // $myVar holds the value "hello goodbye"
    $myVar "hello";                    // $myVar holds the value "hello"
    $myVar $myVar " goodbye";        // $myVar holds the value "hello goodbye"
    When you want to append more text to the end of a string that is already assigned to a variable (like in the last line above), you can use the two operators together, like .= :
    PHP Code:
    <?php

    $myVar 
    =  "hello";   // $myVar holds the value "hello"
    $myVar .= " ";       // $myVar holds the value "hello "
    $myVar .= "goodbye"// $myVar holds the value "hello goodbye"

  10. The Following User Says Thank You to traq For This Useful Post:

    ajfmrf (06-15-2013)

  11. #9
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    593
    Thanks
    43
    Thanked 28 Times in 28 Posts

    Default

    No that I understand,thanks for the explanation.I understand it now
    Thanks,

    Bud

  12. #10
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    You're quite welcome. Have you got it working now?

Similar Threads

  1. Retaining hover properties
    By zack.eth in forum CSS
    Replies: 1
    Last Post: 09-29-2007, 07:03 AM
  2. Retaining SESSION using cURL
    By AikenD in forum PHP
    Replies: 1
    Last Post: 06-04-2007, 12:26 PM
  3. Securing PHP files
    By ralitza in forum PHP
    Replies: 7
    Last Post: 05-28-2006, 12:10 PM
  4. PHP Photo Album : Edit CSS to Center while retaining 3 in a row.
    By _scott in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 02-17-2006, 08:25 AM
  5. Retaining Background Colors
    By skisweet in forum JavaScript
    Replies: 4
    Last Post: 07-26-2005, 05:23 AM

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
  •