URL Encode / Decode

Submitted by:Jhon Jhon

Date added:10 August, 2011

Category:PHP

Url Encode is a technique employed in order to convert a string used in a URL into a valid URL forma and decode url

Tags: url encode , url decode

Code Snippet:

<?php
//****************************************************************************************
//Created by vir0e5
//My blog --> http://vir0e5.blogspot.com
//Forum --> http://indonesian-cyber.org
//Greetz --> Allah S.W.T , Mohammad S.A.W
//All Crew : indonesiancoder,indonesianhacker, devilzc0de, tecon, phl
//****************************************************************************************

echo"<title>URL Encode / Decode</title>";
echo"<div align=center>URL Encode / Decode";

$bandit= stripslashes($_POST['c0de']);
if ($bandit == "")
{
$bandit = $_GET['c0de'];
}

$action = $_POST['action'];
if ($action == "")
{
$action = $_GET['action'];
if ($action == "encode"){
$action = "enc0de";
}
elseif ($action == "decode")
{
$action = "dec0de";
}
}

switch($action){
case "enc0de":
$output = urlencode ($bandit);
if(!$output){
echo 'Ada yang salah!!!';
}

echo"<center><table width='380'><td>";
echo"<br><center>"urlencode() function"</center><hr></br>";
echo "<p> Input : " . $bandit . "</p>";
echo "<p> Output: " . $output ."</p>";
echo "<p><a href='javascript:history.back(0);'> << Back </a></p>";
break;

case "dec0de":
$output = urldecode($bandit);
if(!$output){
echo 'Ada yang salah!!!';
exit;
}

echo"<center><table width='380'><td>";
echo"<br><center>"urldecode() function"</center><hr></br>";
echo "<p> Input : " . $bandit . "</p>";
echo "<p> Output : " . $output ."</p>";
echo "<p><a href='javascript:history.back(0);'> << Back </a></p>";
break;

default:
echo"<p>Input your text on text area...and enjoy it!!</p>";
echo '<form id="form1" name="form1" method="post" action="?encode/vir0e5\decode">
<p>
<textarea name="c0de" id="c0de" rows=8 cols=40 ></textarea>
</p>

<p>Pilih yang mau di cari</p>

<p><input type=radio name="action" id="action" value="enc0de">Encode</p>
<p><input type=radio name="action" id="action" value="dec0de">Decode</p>

<input type="submit" class = "button" name="submit" id="submit" onClick="
if(c0de.value==\'\'){alert(\'mana teksnya kang???\'); return false;}" value="Submit" />
<input type="reset" name="reset" class="button" value="Reset"/>

</p>
</form>';

break;
}

?>
 
 

Comments