Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help pls: Full string not being mailed on feedback form

    Hi,

    I have a curious problem and I wonder if its due to my lack of understanding of php/html.
    (I'm completly new at this and just learing as I go)

    I have a string which is echoed on screen fine but when sent as in my feedback form I only get the first word:

    The string is read from a file
    PHP Code:
    $theData fgets($fh);
    echo( 
    "<p>Thank you for supporting us by wanting to contribute towards our</p>");
    echo (
    "<p> $theData </p>");
    echo (
    "<input type='hidden' value=$theData name='Gift'>"); 
    The echo of $theData works fine displaying "Hotel stay"

    In my sendMail.php:

    PHP Code:
    $gift=$_POST['Gift']; 
    $send =
        
    "
        From: $email \n
        Gift: $gift \n
        "
    ;
    mail("""Feedback Form Results"$send"From: $email"); 
    The value gift is only "Hotel".

    Does anyone have any thoughts of where I'm going wrong?

    Thanks in advance.

    KK

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    In your hidden input, try changing

    echo ("<input type='hidden' value=$theData name='Gift'>");

    to

    echo ("<input type=\"hidden\" value=\"$theData\" name=\"Gift\">");

    The backslashes is an escape character, which is used to tell PHP to ignore the next character. In this case, it is used to escape the double quotes around the attribute values so that PHP doesn't treat it as the end of the string.

    By putting quotes around $theData, the whole string will be sent as a $_POST var. As it is now, the script has no way of knowing what the random text 'stay' means, since it isn't attached to the attribute 'value' in any way

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ahhh,
    thanks, It works now.
    Thanks for the explanation too it was really helpful.


    KK


  •  

    Posting Permissions

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