Jump to content

$_GET and $_POST with foreign languages, specifically Hebrew


aooga

Recommended Posts

I have a textbox where the user inputs data which is sent to another php file. When the user types in hebrew, it is transferred correctly with POST but not with GET. With POST I get א (the correct input) and with GET I get ×. How can I get it to work with GET?

I've isolated the problem to as little code as I can (the actual application uses ajax), here it is:

test.php:

<script type="text/javascript">
function process() {
input = document.getElementById("input").value;
url = "test2.php";
url += "?input=" + input;
window.location.href = url;
}
</script>	

<form action='test2.php' method='post'>

<textarea id = 'input' name = "input"></textarea>

<input type="submit" value="Click here to POST" />

</form>

<a href="javascript:process()">Click here to GET</a>

test2.php just gets the get or post.

<?php

$input2 = $_POST['input'];
$input = $_GET['input'];
echo $input;
echo $input2;

?>

Link to comment
Share on other sites

You could try passing the string through JavaScript's escape function:

 

window.location.href = escape(url);

 

I've got little experience with this though so I don't know if it will work...

Link to comment
Share on other sites

You could try passing the string through JavaScript's escape function:

 

window.location.href = escape(url);

 

I've got little experience with this though so I don't know if it will work...

 

Oops, just realised I showed you the escape function in the wrong place, should be:

 

input = escape(document.getElementById("input").value);

Link to comment
Share on other sites

Didn't work for me: now I get '%u05D0'

<script type="text/javascript">
function process() {
input = document.getElementById("input").value;
url = "test2.php";
url += "?input=" + escape(input);
window.location.href = url;
}
</script>	

<form action='test2.php' method='post'>

<textarea id = 'input' name = "input"></textarea>

<input type="submit" value="Click here to POST" />

</form>

<a href="javascript:process()">Click here to GET</a>

<?php

$input2 = $_POST['input'];
$input = $_GET['input'];
$input = urldecode($input);
echo $input;
echo $input2;

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.