I don't get the complete variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
reddurango
Forum Newbie
Posts: 13
Joined: Sun Aug 16, 2009 9:17 am

I don't get the complete variables

Post by reddurango »

Hi good day i'm having a problem with the post and get methods 'cause i'm sending information trough this mehtods but it arrived incomplete, for example i send "Las Flores" and only arrives "Las" is like if the space did a break, help please
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: I don't get the complete variables

Post by Darhazer »

Post some code? How you are sending (via a HTML form -then post the HTML, or via a script - then post a script), how you are using the variable (post the script)
reddurango
Forum Newbie
Posts: 13
Joined: Sun Aug 16, 2009 9:17 am

Re: I don't get the complete variables

Post by reddurango »

well this is the thing i'm using forms, and i use a hidden line for send the information like this:

Code: Select all

<td>Hotel: </td><td><?php echo $hotel ?><input type="hidden" name="hotel" value=<?php echo $hotel ?>></td>
This code prints: Hotel: Las Flores (and hidden is the input)

as you can see i print the text and is complete but when i send the form trough POST and i get it in this code:

Code: Select all

$message.=" Hotel:  " . $_POST['hotel'] . "\n";
This prints: Hotel: Las

Here only shows 'til the first space
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: I don't get the complete variables

Post by Darhazer »

You are missing the quotes in the value attribute of the input, this is why you are losing everything after the first space. It should be:

Code: Select all

<td>Hotel: </td><td><?php echo $hotel ?><input type="hidden" name="hotel" value="<?php echo $hotel ?>"></td>
Or even better:

Code: Select all

<td>Hotel: </td><td><?php echo htmlspecialchars($hotel) ?><input type="hidden" name="hotel" value="<?php echo htmlspecialchars($hotel) ?>"></td>
Post Reply