Jump to content

Archived

This topic is now archived and is closed to further replies.

aooga

$_GET and $_POST with foreign languages, specifically Hebrew

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;

?>

Share this post


Link to post
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...

Share this post


Link to post
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);

Share this post


Link to post
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;

?>

Share this post


Link to post
Share on other sites

×

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.