$_POST losses data

Discussion in 'PHP' started by MichaelLewis, May 18, 2008.

  1. #1
    When my form fields data consists of more than one string, $_POST only picks up the first string.

    e.g. form field name=street
    form filed entry = President Kennedy
    $Street = $_POST[street];
    Result: $Street contains "President"

    Am I doing something wrong?

    How do I get the full field content?

    Thanks
    Michael
     
    MichaelLewis, May 18, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Post your HTML form and the exact code.
     
    mwasif, May 18, 2008 IP
  3. MichaelLewis

    MichaelLewis Active Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #3
    Sorry, I just found out that is not the problem.

    The problem seems to be in the following statement/

    Street:<input type=\"text\" readonly name=\"estreet\" size=\"25\" MaxLength=30 value=$Street>

    $Street does contain the full field entry after using $_$POST but what is displayed in the new form (above statement) only shows the first string of $Street content.

    Thanks
    Michael
     
    MichaelLewis, May 18, 2008 IP
  4. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #4
    Use quotes around $Street.
    <input type=\"text\" readonly name=\"estreet\" size=\"25\" MaxLength=30 value=\"$Street\">
    PHP:
     
    mwasif, May 18, 2008 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #5
    Or to avoid \ simply use ' (single quote) instead of double like

    :<input type='text' readonly name='estreet' size='25' MaxLength=30 value='$Street'>
     
    mwasif, May 18, 2008 IP
  6. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #6
    Oh and another hint, when getting data from arrays use:

    $_POST['street'] not $_POST[street].

    4-6x faster and reduces the risk for errors.

    e.g.

    If I had earlier done:

    define('street', 'blah');
    then it would retrieve $_POST['blah'] and not $_POST['street'].

    - Dan
     
    Danltn, May 18, 2008 IP
  7. MichaelLewis

    MichaelLewis Active Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #7
    A million thanks! (I should have asked you sooner - I would have saved 8 hrs of my time.)
     
    MichaelLewis, May 18, 2008 IP