473,378 Members | 1,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

URL parameter En-Decoding problem

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_Auswahlmaske.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_returnValue = 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('parent','alphasuche.php?
name='+document.form1.name.value+'&plz='+document. 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.
Jul 17 '05 #1
1 3019
Matthias Stern wrote:
(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.

<snip>

1. In client side encodeURIComponent()
2. In PHP, directly getting the param like echo $_GET['foo']

For me, the above setup seems to work without any trouble.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ion Chalmers Freeman | last post by:
Um, I think XMLSPY is wrong about this, but it was surprising, so I wanted to check. my dtd has <!ENTITY % en "value"> and <!ATTLIST element attribute CDATA #FIXED "%en;"> so, when I generate...
1
by: Jack | last post by:
Hi, I am working on a asp page where I am opening a recordset object using an Access stored query named "GMISExpenseCombo". I have to use this resultset with various fields in the page. Howeve,r...
2
by: eczino | last post by:
I currently have a web form posting back to a SQL table using a Stored Procedure. Part of this SP is that it pulls data from another table and inserts a new row into the registration table. I...
1
by: Marius Rus | last post by:
Could anyone tell me please how to write from the c# code in an parameter? For example I have an report that it is asking for a client code as the parameter. Now it is showing the interface from...
1
by: Ryu, Kyoung-Seok | last post by:
I read brilliant ManWrap Lib article in MSDN Mag (http://msdn.microsoft.com/msdnmag/issues/05/04/C/default.aspx) I'm making Internet Authenticatioin Server Extension DLL This DLL must be only...
3
by: Yaron | last post by:
Hi, I have a procedure in which I need to receive a parameter which is actually the address of another procedure to call. For example: createEditBox(onSuccess, onFailure) The onSuccess and...
3
by: Bob | last post by:
When entering some functions, when the parameter list is shown there are definintions for the items in the paramater list. For example when you enter MID( you get the definition of the first...
3
by: Rich Robinson | last post by:
Hi, I have a web service method which takes a DateTime type as a parameter. The service is UK based, and the dates are passed in to the service in the UK format dd/MM/yyyy. On a recent...
2
by: bob | last post by:
Hi, Is this a bug? SqlClient Parameters collection Prior to the following snippet a set of parameters were declared and added to the parameters collection. The parameter values I originally...
14
by: bill | last post by:
Can someone please show me an example of passing a string value into an sql statement in vb 2005? Something like this is what I'm after: Dim sqlButton1 As String = "Select * from tblAssets where...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.