dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

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

  1. #1
    Join Date
    Mar 2012
    Posts
    1

    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:
    document.myform.submit();
    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);

    document.myform.submit();
    }

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    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.

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