Hi, i am new about PHP, I got a problem about using POST method in HTML and get it in PHP ...

I use a simple form in HTML and put a very long string of a variable, i.e. data ...

<form method="post" action="form.php" id="form1" name="form1">
<input type="hidden" id="data" name="data" value="VERY LONG STRING">
<input type="submit" value="Click Me!" />
</form>

and I use a simple PHP to get the value back ...

<?php
if ($HTTP_POST_VARS["datasss"]) {
echo "<p>Hello, ".$HTTP_POST_VARS["data"]."!";

echo "\n";

}
?>

It seems simple, but the strange thing is that the data obtain in PHP is a little bit different (seems longer) from the HTML one ...

btw, i am using PHP 4.2.2, Linux RH8, Apache 2.0.40 ... while i got no problem when using Windows OS ... Does any PHP expert know why does it happen and how to solve it ?

really thx a billion ~~~

    What i dont understand is why your getting data returned at all, because you have no where set a value for $HTTP_POST_VARS['datasss']

    and i think your problem lies with stripslashes/addslashes

    when you create a variable unless you have told php to treat quotes and single quotes as a string, php will automatically add slashes to them

    eg.

    $var = "she said "don't do that""; // will give you an error unexpected T_STRING

    this is because php thinks your trying to coplete the creation of the variable

    $var = "she said \"don't do that\""; // will result in no errors because you have told php to treat them as part of your string

    when creating strings in a form php automatically adds them when you try and show them on your page

    so if you had something like value=i said "this to her"

    <?
    echo $HTTP_POST_VARS["data"]; // would show - i sed \"this to her\"
    ?>
    

    so if you dont want the slashes there try using this

    <?
    echo stripslashes($HTTP_POST_VARS["data"]);
    ?>
    

    hth

      really thx for your reply, let me make it clearer ...

      the long string doesn't contain any quotes/single quotes inside ...

      actually the string stores plenty of 'points' data that i need to redraw it by using PHP ... the data is somehow like this ...

      line_366.45_388.7_386.5_437.7_1_0x000000_false-line_386.5_437.7_402.1_466.65_1_0x000000_false-line_402.1_466.65_407.65_472.25_1_0x000000_false-line_407.65_472.25_408.75_472.25_1_0x000000_false-line_408.75_472.25_408.75_470_1_0x000000_false-line_408.75_470_405.45_468.9_1_0x000000_false-
      ...

      however ... when i arrive PHP, the data is modified ... like ...

      line_407.65_472.25_408.75_472.25_1_0x000000_false-line_408.75_472.25_408.75_470_1_0x000000_false-line_408.75_470_405.45_468.9_1_0x000000_false-data=line_152.6_95.75_158.15_93.55_1_0x000000_false-line_158.15_93.55_173.75_92.45_1_0x000000_false-
      ...

      it seems that the string is being "inserted" by itself in somewhere ...

        Just a side note, you may want to change to the method of retrieving your POST variables...

        // Instead of:
        $HTTP_POST_VARS['data'];  //This method is deprecated
        
        // Do:
        $_POST['data'];  //This is the preferred method for calling the values in the super global arrays (GET, POST, SESSION, etc...)
        
          Write a Reply...