Skip navigation.

Harold's Home

   Home
  
XML version of this site

PHP Scripts

Index
CLI fun
Mail on 404
HB-NS (NewsScript)

Downloads

Applescripts
APOD to Desktop
Dreamweaver Extensions

Stuff

Writings
Other stuff
Central Grinder

OOOk Default:

VJ stuff
VJ Tools
Bananas
Strippers
Sample Movies

News

Host your own PHP urldecoder
I just got a request from someone who wanted to put the urldecoder/urlencoder I have here in the PHP section on their own site. Sure, here's the code for all who want it:

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$translate = $_REQUEST['translate'];
$actie = $_REQUEST['actie'];

echo "<fieldset><legend>URL decode or encode the following text:</legend>\n";
echo "<form method=\"get\" action=\"$PHP_SELF\">\n";
echo "<input type=\"text\" name=\"translate\" size=\"60\" value=\"$translate\" /><br /><br />\n";
echo "<label for=\"decode\">urldecode</label> <input type=\"radio\" name=\"actie\" value=\"decode\"";
if ((!isset ($actie)) || ($actie == "decode"))
{
    echo " checked=\"checked\"";
}
echo " id=\"decode\" />   <label for=\"encode\">urlencode</label> <input type=\"radio\" name=\"actie\" value=\"encode\"";
if ($actie == "encode")
{
    echo " checked=\"checked\"";
}
echo " id=\"encode\" /><br />\n";
echo "<input type=\"submit\" />\n";
echo "</form>\n";
echo "</fieldset>\n";
echo "<br /><br />\n";
echo "<table>\n<tr>\n<td>";
if (isset ($translate))
{
    echo "original:</td><td>$translate</td></tr>\n<tr>\n<td>";
    if ($actie == "decode")
    {
     echo "urldecoded:</td><td>";
     $translate = htmlspecialchars(urldecode($translate));
     echo "<strong>$translate</strong>";
    }
    if ($actie == "encode")
    {
        echo "urlencoded:</td><td>";
        $translate = urlencode($translate);
        echo "<strong>$translate</strong>";
    }
}
echo "</td></tr>\n</table>\n";
?>


Enjoy.

Show all items | Read all items

About, copyright, privacy and accessibility | Mail