HTML:
<! 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" >
< Head >
< Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" />
< Title > MD5 </ Title >
< Script SRC = "Jquery-1.4.2.min.js" Type = "Text/JavaScript" > </ Script >
< Script Type = "Text/JavaScript" >
Function Sendvalue (){
Alert ($ ( " # Source " ). Val ());
$. Ajax ({
Type: ' Get ' ,
URL: ' Md5service. php ' ,
Data: {MD5: $ ( ' # Source ' ). Val ()},
Error: Function (){
Alert ( " Error occured !!! " );
},
Success: callback
});
Return True ;
}
Function Callback (back ){
Alert (back );
$ ( " # Result " Pai.html (back );
}
</ Script >
</ Head >
< Body >
< Form Action = "Md5service. php" Method = "Get" Target = "_ Self" Name = "Form1" >
< Label > Enter the data to be encrypted: </ Label > < Input Name = "Source" Type = "Text" ID = "Source" /> < BR />
< Input Type = "Button" Value = "MD5" Onclick = "Sendvalue ()" />
</ Form >
< P > Result: </ P >
< Div ID = "Result" >
Result
</ Div >
</ Body >
</ Html >
PHP:
<! 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 " >
< Head >
< Meta HTTP - Equiv = " Content-Type " Content = " Text/html; charset = UTF-8 " />
< Title > MD5 </ Title >
</ Head >
< Body >
<? PHP
$ Source = $ _ Get [ " MD5 " ];
$ Md5value = MD5 ( $ Source );
Echo $ Md5value ;
$ Con = Mysql_connect ( " Localhost " , " Root " , " Niuniu " );
If ( ! $ Con )
{
Die ( " Connect error! " ) . Mysql_error ();
}
Mysql_select_db ( " My_md5 " , $ Con );
$ SQL = " Insert into md5s (source, MD5) values (' " . $ Source . " ',' " . $ Md5value . " ') " ;
Mysql_query ( $ SQL );
Mysql_close ( $ Con );
?>
</ Body >
</ Html >