Results 1 to 2 of 2

Thread: data not set in $_post array after javascript submit

  1. #1
    Join Date
    Mar 2012

    data not set in $_post array after javascript submit

    I am trying to test "posted" values from a form that has been submitted from a JavaScript function.

    The following code should submit the form:
    do I have to do anything to get data in to the $_post array. this form will be processed by PHP

    below is the code I have so far

    function prep_password()
    var password;
    var hash;
    password = document.myform.passBox.value;
    hash = calcMD5(document.myform.passBox.value);
    password = calcMD5(hash + document.myform.salt.value);
    document.myform.passBox.value = password;
    document.myform.sub.value = "submit";
    var data = $('myform').serialize();
    $.post("index.php", data);


  2. #2
    Join Date
    Dec 2002
    St. Louis, MO, USA
    If this code is within a PHP page and not an external .js file (it won't work if it's in a .js file, as only .php files are processed by the PHP server), then you need to prepend all PHP functions with <?php and append them with ?>, because JavaScript does not recognize PHP code.
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles