Hi there. My website passes information from one page to another via
the URL. it DOESN'T use forms or post/get but rather I build up the url
in page A as a string and use it to link to page B.
My url looks (something)like this
http://www.mysite.com/pageb.php?Passe dUserName='Hest er'&PassedUserO ccupation='Test er'
I don't want users to be able to type in what ever entries they like,
but also I would like to hide the entire list of variables so that it
appears something like
http://www.mysite.com/pageb.php?Passe dData=<random looking data here>
Now, I found these functions
function encrypt($string , $key) {
$result = '';
for($i=0; $i<strlen($stri ng); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ ord($keychar));
$result.=$char;
}
return base64_encode($ result);
}
function decrypt($string , $key) {
$result = '';
$string = base64_decode($ string);
for($i=0; $i<strlen($stri ng); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}
return $result;
}
which work nicely on parts of the url giving me
PassedUserName= 'Hester'
xLTf1NfYvtXG5ML HztixerTG5ejO1I g=
PassedUserOccup ation='Tester'
xLTf1NfYvtXG5MP JxOjktODK4eKmib XX59rG5Zs=
but I cannot encrypt the whole string
PassedUserName= 'Hester'&Passed UserOccupation= 'Tester' unless i replaced
the & with another character for example but then I would have to
somehow split the string into the two variables, and be able to use
these values in my code.
I guess appending a $ to the start of the decoded string isn't going to
work? (I doubt my problem would be that easily solved!)
Sorry, I'm a bit green when it comes to Php programming and I've looked
through the PHP manual and tried many different ways of doing this
before I had to ask.
Thanks in advance for any/all assistance
the URL. it DOESN'T use forms or post/get but rather I build up the url
in page A as a string and use it to link to page B.
My url looks (something)like this
http://www.mysite.com/pageb.php?Passe dUserName='Hest er'&PassedUserO ccupation='Test er'
I don't want users to be able to type in what ever entries they like,
but also I would like to hide the entire list of variables so that it
appears something like
http://www.mysite.com/pageb.php?Passe dData=<random looking data here>
Now, I found these functions
function encrypt($string , $key) {
$result = '';
for($i=0; $i<strlen($stri ng); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ ord($keychar));
$result.=$char;
}
return base64_encode($ result);
}
function decrypt($string , $key) {
$result = '';
$string = base64_decode($ string);
for($i=0; $i<strlen($stri ng); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}
return $result;
}
which work nicely on parts of the url giving me
PassedUserName= 'Hester'
xLTf1NfYvtXG5ML HztixerTG5ejO1I g=
PassedUserOccup ation='Tester'
xLTf1NfYvtXG5MP JxOjktODK4eKmib XX59rG5Zs=
but I cannot encrypt the whole string
PassedUserName= 'Hester'&Passed UserOccupation= 'Tester' unless i replaced
the & with another character for example but then I would have to
somehow split the string into the two variables, and be able to use
these values in my code.
I guess appending a $ to the start of the decoded string isn't going to
work? (I doubt my problem would be that easily solved!)
Sorry, I'm a bit green when it comes to Php programming and I've looked
through the PHP manual and tried many different ways of doing this
before I had to ask.
Thanks in advance for any/all assistance
Comment