function nuevoAjax(){ var xmlhttp=false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if(!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp;}
<html><head> <title>Manejo Basico de Ajax</title></head><body><div style="position: relative; width: 600px; left: 50%; margin-left: -300px; text-align: center;"><h2>Base64 Cipher/Decipher</h2><h1>by Hackxcrack</h1> <br> <form action="index.php" method="post"> <input type="text" name="texto"><br><br> <input type="submit" name="btn_ope" value="Cipher"> <input type="submit" name="btn_ope" value="Decipher"> </form></div></body></html>
<?phpif(isset($_POST['btn_ope']) && $_POST['texto'] != ""){ $text_procesado=""; if($_POST['btn_ope'] == "Cipher") { $text_procesado = base64_encode($_POST['texto']); } else if($_POST['btn_ope'] == "Decipher") { $text_procesado = base64_decode($_POST['texto']); }}?>
<?phpif(isset($_POST['btn_ope']) && $_POST['texto'] != ""){ $text_procesado=""; if($_POST['btn_ope'] == "Cipher") { $text_procesado = base64_encode($_POST['texto']); } else if($_POST['btn_ope'] == "Decipher") { $text_procesado = base64_decode($_POST['texto']); }}?><html><head> <title>Manejo Basico de Ajax</title></head><body><div style="position: relative; width: 600px; left: 50%; margin-left: -300px; text-align: center;"><h2>Base64 Cipher/Decipher</h2><h1>by Hackxcrack</h1> <br> <form action="index.php" method="post"> <input type="text" name="texto"><br><br> <input type="submit" name="btn_ope" value="Cipher"> <input type="submit" name="btn_ope" value="Decipher"> </form> <br> <?php if(isset($text_procesado) && $text_procesado != "") { echo $text_procesado; } ?></div></body></html>
<html> <head> <title>Manejo Basico de Ajax</title> <script type="text/javascript" src="ajax.js" language="javascript"></script> </head> <body> <div style="position: relative; width: 600px; left: 50%; margin-left: -300px; text-align: center;"> <h2>Base64 Cipher/Decipher</h2> <h1>by Hackxcrack</h1> <br> <form action="#"> <input type="text" name="texto"><br><br> <input type="button" name="btn_ope" value="Cipher"> <input type="button" name="btn_ope" value="Decipher"> </form> <br><br> <div id="contenedor" style="text-align: center;"></div> <!-- Contenedor para el ajax --> </div> </body> </html>
<?phperror_reporting(0); //no queremos alertas if(isset($_POST['btn_ope']) && $_POST['texto'] != "") { if($_POST['btn_ope'] == "Cipher") { echo base64_encode($_POST['texto']); } else if($_POST['btn_ope'] == "Decipher") { echo base64_decode($_POST['texto']); } } ?>
function nuevoAjax(){ var xmlhttp=false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp;}function operar(btn){ var contenedor = document.getElementById('contenedor'); var pag = 'funcion.php'; var texto = "texto="+document.getElementById('texto').value+"&btn_ope="+btn.value; var ajax = nuevoAjax(); ajax.open("POST", pag, true); contenedor.innerHTML='Cargando...'; ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); ajax.setRequestHeader("Content-length", texto.length); ajax.setRequestHeader("Connection", "close"); ajax.onreadystatechange=function() { if (ajax.readyState==4) { contenedor.innerHTML = ajax.responseText; } } ajax.send(texto);}
<html><head> <title>Manejo Basico de Ajax</title> <script type="text/javascript" src="ajax.js" language="javascript"></script></head><body><div style="position: relative; width: 600px; left: 50%; margin-left: -300px; text-align: center;"><h2>Base64 Cipher/Decipher</h2><h1>by Hackxcrack</h1> <br> <form action="#"> <input type="text" name="texto" id="texto"><br><br> <input type="button" value="Cipher" onclick="operar(this);"> <input type="button" value="Decipher" onclick="operar(this);"> </form> <br><br> <div id="contenedor" style="text-align: center;"></div> <!-- Contenedor para el ajax --></div></body></html>
<?phperror_reporting(0); //no queremos alertasif(isset($_POST['btn_ope']) && $_POST['texto'] != ""){ if($_POST['btn_ope'] == "Cipher") { echo base64_encode($_POST['texto']); } else if($_POST['btn_ope'] == "Decipher") { echo base64_decode($_POST['texto']); }}else{ echo "Error";}?>
var texto = "texto="+document.getElementById('texto').value+"&btn_ope="+btn.value;
"texto="+document.getElementById('texto').value+document.getElementById('text').value+"&btn_ope="+btn.value;
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");ajax.setRequestHeader("Content-length", texto.length);ajax.setRequestHeader("Connection", "close");
var texto = "texto="+document.getElementById('texto').value+document.getElementById('text').value+"&btn_ope="+btn.value;
if(isset($_POST['btn_ope']) && $_POST['texto'] != "" && $_POST['text']!="")