WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A Simple Ajax Example to calculate the MD5 hash of a string.
Categories : AJAX, MD5, Security, Web Services Click here to Update Your Picture
Bobin R
Date : Feb 19th 2007
Grade : 4 of 5 (graded 2 times)
Viewed : 10967
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Bobin R
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

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
Function to generate readable/remeberable random password
Categories : PHP, Security, Security
Miguel
Categories : AJAX, AJAX
Zephyr: AJAX Based Framework for PHP5 Developers
Categories : PHP, AJAX, Frameworks, Java Script, Web Applications
IPhider Obscure Any URL Anonymity connection lores obfuscation corporate survival.
Categories : PHP, Algorithms, Security, URLs
A PHP function to encrypt and decrypt a number or string or a combination of the two.
Categories : PHP, Encryption, Security
Simple AJAX (Jquery) Star Rating System
Categories : PHP, AJAX
javascript cookie settings
Categories : PHP, C++, AJAX
Encoding data using PGP via PHP's proc_* functions
Categories : Cryptography, Security, Email, PHP, PGP
Why it is not possible to preset a value in a file upload field
Categories : HTML, Security, Filesystem, Beginner Guides
send_mail function to defeat Header Injection Hacking/Spamming
Categories : PHP, Email, Form Processing, Security
JSON File Upload
Categories : PHP, AJAX, Filesystem
Password using php, Javascript, and html form
Categories : Security, PHP, Authentication, Java Script
IPTables Bandwidth statics
Categories : PHP, Security, Network
Creates a CAPTCHA image in PHP, which displays 5 numbers stored in a session.
Categories : PHP, GD image library, Form Processing, Security