#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    33
    Rep Power
    15
    Can I encode parameters I am passing through URL.
    For example.

    <a href="aas.php3? xyz=5&abc=yes&pqr=tom">Next</a>
    I would like to encode "xyz=5&abc=yes&pqr=tom" as one can do in JSP.
    Can somebody help me if it can be done in PHP3.
    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    15
    You should use urlencode() function to encode the url and urldecode() function to decode the string : the syntaxes of both are as follows:
    string urlencode(string str);
    example : echo '<A HREF="nik.php3?xyz=', urlencode ($userinput), '">';

    string urldecode(string str);
    Hope This serves the purpose.




    ------------------
    Nikunj Virani
    MYSQL/PHP/XML
    This is the world of Nikunj
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    33
    Rep Power
    15
    I am sorry. I think have not posted query properly. I mean to I want to hide/encode value of variables I am passing through
    URL. for example.
    <form method="post" action="aas.php3? xyz=5&abc=yes&pqr=tom">
    I want to hide/encode "xyz=5&abc=yes&pqr=tom" so that viewer can not see variable values OR variable names.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Canada
    Posts
    35
    Rep Power
    15
    <form method="post" action="aas.php3? xyz=5&abc=yes&pqr=tom">
    I want to hide/encode "xyz=5&abc=yes&pqr=tom" so that viewer can not see variable values OR variable names.
    -----------------------------------------------------------------------------------------------------------------------
    <form method="post" action="aas.php3">
    //if you choose "post": then everything is hidden; don't use '?' after your file name because this is for the 'get' fonction (mean don't mix both)
    <input type="hidden" name="xyz" value="5">
    <input type="hidden" name="abc" value="yes">
    <input type="hidden" name="pqr" value="tom">
    //for each value you wish to pass along the form; 'hidden' means the user will never see it...


    Hope this helps!
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    33
    Rep Power
    15
    If this is the case then how to hide variable values of $xyz, $abc, $pqr.
    <form method="post" action="aas.php3?xyz=<? echo $xyz&abc=<? echo $abc ?>&pqr=<? echo $pqr ?>
    Guide me when to use post and get.
    Thanks
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    15
    There is not much difference in between the two we can use any of the two but the major difference amongst the two is that Get method passes the data through URL string while POST method does not use URL string to pass the data.For example make a sample form and pass the value with both the methods and check URLS u will understand better.



    ------------------
    Nikunj
    MYSQL/PHP/XML
    ** Expertise comes with experiece ** Nikunj
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Herne Bay, Kent, UK
    Posts
    30
    Rep Power
    15
    Another way to do it would be to construct the variable assignments within a string...

    $myVarBlock="$xyz=5;$abc="yes";$pqr="tom"";
    [NOTE: The semi-colons and escaped quotes...we're going to evaluate this string later!! ]

    Then use the encrypt (I don't know if this is installed in all systems - I've only seen it mentioned in the O'Reilly PHP Pocket Reference) function along the lines of:

    $myCryptBlock=encrypt($myVarBlock,1,"myPassword");
    [I don't know what the 1 does]
    Then pass that in the href:
    <a href="aas.php3?cb=$myCryptBlock">Next</a>

    In aas.php3, use the decrypt function to get myVarBlock back

    $myVarBlock=decrypt($cb,1,"myPassword");

    And then finally evaluate the contents of myVarBlock, thus setting the variables to the values you want...

    eval($myVarBlock);

    I hope this works, let me know what you think!


    [This message has been edited by biscuit (edited September 04, 2000).]

    [This message has been edited by biscuit (edited September 04, 2000).]

Similar Threads

  1. passing parameters to crystal report from vb6
    By sghimire in forum Visual Basic Programming
    Replies: 4
    Last Post: October 18th, 2004, 07:31 AM
  2. https parameters in url
    By alkesh in forum Java Help
    Replies: 0
    Last Post: November 20th, 2003, 09:36 AM
  3. Newbie question about URL Parameters
    By hamr2u in forum ASP Programming
    Replies: 4
    Last Post: November 20th, 2003, 01:17 AM
  4. passing variables through the url?
    By miseria in forum PHP Development
    Replies: 6
    Last Post: October 26th, 2003, 06:16 PM
  5. Passing parameters to an Excel File
    By eris in forum Java Help
    Replies: 0
    Last Post: October 2nd, 2003, 12:00 PM

IMN logo majestic logo threadwatch logo seochat tools logo