...

View Full Version : Help pls: Full string not being mailed on feedback form



NinjaMoo
06-28-2007, 02:34 PM
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


$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:



$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

whizard
06-28-2007, 02:39 PM
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

NinjaMoo
06-28-2007, 04:54 PM
Ahhh,
thanks, It works now.
Thanks for the explanation too it was really helpful.
:thumbsup:

KK



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum