1

I have a form that I'm submitting using javascript. However, one of the checks it does uses a php script that queries an API and gets a user's password. This is for the purposes of form validation (i.e. if password doesn't match what we have on file..)

I'm using a php script to decode the password like this

function submitForm() {

    var options = {
        decoded_password: '<?php echo abc_decode($contactInfo['Password'])?>',
    }

    if (jQuery('#current_password').val() != options.decoded_password &&  $psc('#current_password').val()) {
        render_alert('Your current password does not match what we have on file.');
        return false;

    } else {
        $psc('#account-information').submit();
        document.getElementById("account-information").reset();
    }

Page loads, great, submit form, great. However, the variable is remembered from the first page load, so if I try to change the password again, it says my password doesn't match what is on file. If I reload the page, no problem.

Is there any way to change the value of $contactInfo['Password'] in javascript without a page reload?

1 Answer 1

1

You could try making an AJAX call instead. This won't require a page reload, but will still give you the opportunity to send the data back to the server. If you store the data in the $_SESSION variable it will persist across multiple calls.

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

1 Comment

Could I get an example of how you would do that @OlfactoryNinja? We have the session storing most data already.

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.