I've been trying to make a base converter that allows a guest to input a custom frombase and tobase, but every time I try to code these values as variables determined by the form, I get an error. Is it possible to do what I'm trying to do, or should I settle for just having the frombase and tobase limited to the common options?
Are you taking about php base64 encoding and decoding ?? <?php $str = 'This is an encoded string'; echo base64_encode($str); ?> The above example will output: VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw== To Decode: <?php $str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='; echo base64_decode($str); ?> The above example will output: This is an encoded string
You basically want to make two forms, one to decode and one to encode right? I'm new to PHP but it should be pretty simple to make. Create a file called base.php and put this in it <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Encode & Decode</title> </head> <body> Encode:<br /> <form action="base.php" method="post"> <input name="encode" size="50" /> <input type="submit" value="Submit" /> </form> <br /> Decode:<br /> <form action="base.php" method="post"> <input name="decode" size="50" /> <input type="submit" value="Submit" /> </form> <br /> <?php $encode = $_POST['encode']; $decode = $_POST['decode']; if ($encode == true) { echo base64_encode($encode); } elseif ($decode == true) { echo base64_decode($decode); } ?> </body> </html> Code (markup):