if value contains & and i am using get method tp pass data to another form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vishal

    if value contains & and i am using get method tp pass data to another form

    hi

    i am using get method to pass data from one form to another and my
    value may contain & symbol. so when this is case the value after & sign
    is truncated which is logically true.

    so what should i do to solve this problem

    and if value contain ? symbol then it will make any difference?????
    i have not checked this but just it came in mind right now so i am
    asking you.


    is there any otehr characters which i should consider except & and ?
    while using get methos to pass data from one form to another


    thxs for your reply in advance

  • Erwin Moller

    #2
    Re: if value contains & and i am using get method tp pass data to another form

    vishal wrote:
    [color=blue]
    > hi
    >
    > i am using get method to pass data from one form to another and my
    > value may contain & symbol. so when this is case the value after & sign
    > is truncated which is logically true.
    >
    > so what should i do to solve this problem
    >
    > and if value contain ? symbol then it will make any difference?????
    > i have not checked this but just it came in mind right now so i am
    > asking you.
    >
    >
    > is there any otehr characters which i should consider except & and ?
    > while using get methos to pass data from one form to another
    >
    >
    > thxs for your reply in advance[/color]

    Hi,

    You should ALWAYS url-encode your values.
    Look at this:

    $name= "Zaphod Breeblebox";
    $age = "how should I know?";
    $favfood = "fish&fries ";

    Now if you want to send that as an url in name/value pairs, do this:

    $url = "http://www.yoursite.co m/somescript.php? ";
    $url .= "name=".urlenco de($name);
    $url .= "&age=".urlenco de($age);
    $url .= "&favfood=".url encode($favfood );

    now $url contains a valid encoded url with name/value pairs.

    header ("Location: $url");


    Hope that helps.

    Regards,
    Erwin Moller

    Comment

    Working...