Hello!
I've got a Javascript-PHP encoding problem.
(1) Here is the short version:
=============== ===============
I'm sending a form textfield via Javascript(!) as URL parameter (GET)
from one php-page to another and want to send all possible special
characters like !"§$%&/()=?#öäÜ and so on to the target page. On the
target page I read the URL-parameter via PHP and use it parameter as
input for a MySQL LIKE command within a SELECT command.
My problem: Special Characters are not decoded properly! I encoding on
the source file with Javascript and encoding on the target side via PHP
but found no way to make it work.
(2) Here is the detailed version:
=============== =============== ===
I have a php-file "alphasuche_Aus wahlmaske.php". In this php-file I have
a form with one textfield named "name".
The entry in this textfield is used for a search in a MySQL Database.
When the "submit"-button is pressed the entered value is passed to
another php-file named "alphasuche.php " where the entered value is used
for a Database search with the MySQL LIKE- command.
Here is the Javascript(!)-command which sends the entered value to the
"alphasuche.php " file:
--begin--
<script type="text/JavaScript">
// The typical Macromedia Dreamweaver "Go To URL"-command
function MM_goToURL() { //v3.0
var i, args=MM_goToURL .arguments; document.MM_ret urnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+ args[i+1]+"'");
}
....
// This part sends the "name" form textfield
MM_goToURL('par ent','alphasuch e.php?
name='+document .form1.name.val ue+'&plz='+docu ment.form1.plz. value);
....
</script>
--end--
So far so good. Everything is fine until I want to use special
characters.
It is necessary that the search-String (form field "name) can do
following things:
Input in "name" ... Function
---------------------------------------------------------------
%xxx ... Every string matches which ends with "xxx"
%xxx% ... Every string matches which contains "xxx"
xxx% ... Every string matches which begins with "xxx"
My questions
============
(1) How can I get the properly decoded "name" stinrg within the php-
file?
(2) Which encoding do I need? Remeber: encoding in source file is done
via Javascript - decoding in target file is done via PHP.
Thx for any help!
P.S.: I already spent 3 hours looking for a working solution on Google
and PHP-forums etc.
I've got a Javascript-PHP encoding problem.
(1) Here is the short version:
=============== ===============
I'm sending a form textfield via Javascript(!) as URL parameter (GET)
from one php-page to another and want to send all possible special
characters like !"§$%&/()=?#öäÜ and so on to the target page. On the
target page I read the URL-parameter via PHP and use it parameter as
input for a MySQL LIKE command within a SELECT command.
My problem: Special Characters are not decoded properly! I encoding on
the source file with Javascript and encoding on the target side via PHP
but found no way to make it work.
(2) Here is the detailed version:
=============== =============== ===
I have a php-file "alphasuche_Aus wahlmaske.php". In this php-file I have
a form with one textfield named "name".
The entry in this textfield is used for a search in a MySQL Database.
When the "submit"-button is pressed the entered value is passed to
another php-file named "alphasuche.php " where the entered value is used
for a Database search with the MySQL LIKE- command.
Here is the Javascript(!)-command which sends the entered value to the
"alphasuche.php " file:
--begin--
<script type="text/JavaScript">
// The typical Macromedia Dreamweaver "Go To URL"-command
function MM_goToURL() { //v3.0
var i, args=MM_goToURL .arguments; document.MM_ret urnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+ args[i+1]+"'");
}
....
// This part sends the "name" form textfield
MM_goToURL('par ent','alphasuch e.php?
name='+document .form1.name.val ue+'&plz='+docu ment.form1.plz. value);
....
</script>
--end--
So far so good. Everything is fine until I want to use special
characters.
It is necessary that the search-String (form field "name) can do
following things:
Input in "name" ... Function
---------------------------------------------------------------
%xxx ... Every string matches which ends with "xxx"
%xxx% ... Every string matches which contains "xxx"
xxx% ... Every string matches which begins with "xxx"
My questions
============
(1) How can I get the properly decoded "name" stinrg within the php-
file?
(2) Which encoding do I need? Remeber: encoding in source file is done
via Javascript - decoding in target file is done via PHP.
Thx for any help!
P.S.: I already spent 3 hours looking for a working solution on Google
and PHP-forums etc.
Comment