Hi there.
I have this script that passes a variable to Google in order to perform a search. The content of the variable comes form an input field in a form:
<form name="form" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>" method="get">
<input type="text" name="q" value=" Search">
<input name="Submit" type="submit" value=" Search ">
</form>
The variables and the code snippet look like this:
$var = @$_GET['q'];
$trimmed = trim($var);
(...)
echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Search for '" . $trimmed . "' on Google\">Click here</a> to search for <b>"" . $trimmed . ""</b> on Google.</p>";
The problem is that if someone types local special chars into the input field - like words containing â, ä, ø, å, æ, etc. - these characters turn out as ? on Google making the search impossible. How can I keep these characters from being turned into question marks?
If you guys want the entire script let me know. Thanks in advance.