Friday, January 29, 2010

Post all values with variables in data section of jquery ajax

Post all values with variables in data section of jQuery ajax



HTML PART
<script type="text/javascript" src="../js/jquery-1.6.js"></script>
<input type="button" name="postButton" id="postButton" value="Do Add" onclick="doAddAction();"/>


<script language="javascript">
function doAddAction() {
    var a1,a2,a3;
    var a1Val,a2Val,a3Val;
    var urlStr="xmlPost.php";
    var postOrGet="POST";
    var ans;
    a1Val="This is a1 val";
    a2Val="This is a2 val";
    a3Val="This is a3 val";
    var variableAndValue={a1:a1Val,a2:a2Val,a3:a3Val};
    ans=doAdd(urlStr,postOrGet,variableAndValue);
    alert(ans);
}

function doAdd(urlStr,POSTorGET,variableAndValue) {
        var ans="";
        $.ajax( {
                            type: POSTorGET,
                            async: false,
                           url: urlStr,
                           data: variableAndValue,
                            timeout: 9999,
                            cache:false,
                             success: function(msg){ans=msg;},
                            error: function(xhr) {
                                            if (xhr.responseText)         
                                            ans=xhr.responseText;
                                            else
                                            ans="I don't know! My Processor Has Been HACKED!";
                                           
                                                }
                        }
                    );
        return ans;           
    }

Php or any other language part:

<?php
$a1=$_POST['a1'];
$a2=$_POST['a2'];
$a3=$_POST['a3'];
$val=$a1."=".$a2."=".$a3;
if($a1!="" && $a2!="" && $a3!="")
    echo "<br/>Hi ".$val;
else
    echo "Hi There are no any value";
?>


Wednesday, January 13, 2010

encrypt and decrypt in mysql

First you need to create the fields and that fields must be varbinary or blob type and length also must be at least 128 characters long.

 aes_encrypt(VALUE,'mykey')
 aes_decrypt(COLUMN NAME, 'mykey')


INSERT INTO userinfo(add1) VALUES (aes_encrypt('my address','mykey'))
SELECT aes_decrypt(add1, 'mykey') FROM userinfo