0

The ajax request is working but the problem I'm having is how to encrypt the data with my PHP function before the request is made?

Here is the JS I'm trying

$("#sensitive_data").blur(function() {
    alert($(this).val());

    $.ajax({
        url: 'db.php?check=<?php echo $object->encrypting_data('+$(this).val()+') ?>',
        type: 'POST',
        error : function (){ document.title='error'; }, 
        success: function (data) {                  
            alert(data);                    
        }
    });         
});

It works if I pass a static value in the php function

1 Answer 1

3

If I understand right, you're trying to use a PHP function to encrypt client-side data before it's sent to the server.

That's impossible, because you can't call a PHP function on the client-side. I'm also not sure what you want to accomplish.

Sign up to request clarification or add additional context in comments.

5 Comments

hmm thanks what I was thinking but just wanted to confirm, Thanks. Well a follow up question then. How does one encrypt sensitive data in an AJAX call or Request (POST/GET)?
You use SSL/TLS to encrypt it in transport. If you're trying to hide it from the browser user, that's pointless and impossible.
This is for a Mobile web app and I need to encrypt the data, any advice? besides SSL/TLS
@Phil, again, who do you want confidentiality from? It's impossible to avoid letting the user see the data.
There should be no issue with SSL support on a mobile phone if you also happen to expect that phone to support jQuery.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.