|
|
|
|
|
|
| |
A server side script (PHP) is used to calculate the MD5 hash of a string. If the Request Method is selected as 'Ajax' and if the browser supports Ajax, then Ajax is used; else normal form submission occurs. It is an example of a Cross Browser script with backward compatibility.
| <?php
if($_POST['ajaxreq'] == 1){
echo getString($_POST['str'], 1);
exit;
}
function getString($str, $method){
return "<table border='1' width='100%'><tr><td><b>String : </b></td><td>$str</td></tr><tr><td><b>MD5 Hash : </b></td><td>" . md5($str) . "</td></tr><tr><td><b>Request : </b></td><td>" . ($method ? 'Ajax Request' : 'Normal Request') . "</td></tr></table>" ;
}
?>
<html>
<head>
<title>Simple Ajax MD5 Example</title>
<head>
<script type="text/javascript">
<!--
function ajaxPost(frm){
var req = false;
var self = this;
if(window.XMLHttpRequest) {
self.req = new XMLHttpRequest();
}else{
try{
self.req = new ActiveXObject("MSXML2.XMLHTTP");
}catch(e){
try {
self.req = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
if(!self.req || frm.ajaxreq[1].checked)return true;
else{
self.req.open("POST", frm.action, true);
self.req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
self.req.onreadystatechange = function() {
if (self.req.readyState == 4) {
update(self.req.responseText);
}
}
self.req.send(getQueryString());
return false;
}
}
function getQueryString() {
return "ajaxreq=1&str=" + escape(document.forms[0].str.value);
}
function update(str){
document.getElementById("result").innerHTML = str;
}
//-->
</script>
</head>
<script language="Javascript">
</script>
<style type="text/css">
body,table,div{font:normal 11px Verdana, Arial,sans-serif;}
.frmTable{border:1px #333 solid;background:#F9F9F9;width:330px;text-align:justify;}
</style>
</head>
<body>
<table style="width:100%;height:100%;">
<tr><td>
<center>
<form method="post" onsubmit="return ajaxPost(this);" action="ajax-test.php">
<table class="frmTable" border="1" cellpadding="3">
<tr><td colspan="2">Enter a string below to get its MD5 hash. If Request Method is selected as 'Ajax' and if the browser supports Ajax, then Ajax is used; else normal form submission occurs.</td></tr>
<tr><td><u><b>Enter String:</b></u></td><td><input name="str" value="<?php echo $_POST['str'];?>" type="text"> <input value="Go" type="submit"></td></tr>
<tr><td><u><b>Request Method</b></u></td><td><input id="ajax" <?php if($_POST['ajaxreq'] != 0)echo 'checked';?> type="radio" value="1" name="ajaxreq"/><label for="ajax">Ajax </label> <input id="normal" <?php if($_POST['ajaxreq'] == 0)echo 'checked';?> type="radio" value="0" name="ajaxreq"/><label for="normal">Normal</label></td></tr>
<tr><td colspan="2"><div id="result"><?php if(isset($_POST['str']))echo getString($_POST['str'], 0);?></div></td></tr>
</table>
</form></center>
</td></tr></table>
</body>
</html> | | |
|
| A damaged image generator (class) for validating text.
CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart Categories : PHP, PHP Classes, Security, GD image library, Security | | | Zephyr: AJAX Based Framework for PHP5 Developers Categories : PHP, AJAX, Frameworks, Java Script, Web Applications | | | MD5 secured login Categories : PHP, Java Script, Authentication, Security | | | Password Creator: This PHP code exmaple shows how to use bitwise operations on a single variable and using it as a flagged variable. The class generates passwords of a given length using specified characters and the flags. Categories : PHP, PHP Classes, Algorithms, Security | | | Bypassing Plugin / FLASH Activation Categories : Java Script, Web Browsers, Security, Flash | | | Secure URL $_GET Categories : PHP, Data Validation, Security | | | IntrPWD - Security & Encryption Categories : ASP Components, Security | | | The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view. Categories : PHP, PHP Classes, Java Script, AJAX, Databases | | | A PHP function to encrypt and decrypt a number or string or a combination of the two. Categories : PHP, Encryption, Security | | | JSON File Upload Categories : PHP, AJAX, Filesystem | | | Encoding data using PGP via PHP's proc_* functions Categories : Cryptography, Security, Email, PHP, PGP | | | Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page. Categories : PHP, AJAX, HTML and PHP, Java Script | | | A very simple PHP single password cookie based login without usernames. Categories : PHP, Cookies, Security, Beginner Guides | | | Easily Grant Temporary SSH Access to yourself when in remote location Categories : PHP, Linux, Cron, Security | | | cPanel Subdomains Creator - Create cPanel subdomains without logging into cPanel. Let your visitors create their own subdomains without your intervention. Moreover, it will inform if a subdomain is already exists. Categories : PHP, Web Services, PHP Classes | |
|
|
|