• Resolved Randem Systems

    (@randem06)


    HI, This code will work properly on a WordPress local system, it posts correctly. When the form is placed on line it will place the form information on the URL instead of posting it. What is the cause and how to fix it? This code is in the WordPress Admin section.

    	<div>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr width="100%">
    <td width="100%" class="face_padding_cell">
    <form name="MyForm" id="MyForm" onSubmit="return beforeSubmit()" action="" method="POST" enctype="application/x-www-form-urlencoded">
    <input type="hidden" id="MY_BLACKWHITE" name="MY_BLACKWHITE" value="Domain Lists">
    <input type="hidden" id="MY_POST_CODE" name="MY_POST_CODE" value="">
    <input type="hidden" id="type" name="type" value="good">
    <input type="hidden" id="area" name="area" value="display">
    <input type="hidden" id="user" name="user" value="dnb">
    <input type="hidden" id="my_checked" name="my_checked" value="">
    <input type="hidden" id="my_unchecked" name="my_unchecked" value="">
    <input type="hidden" id="my_original" name="my_original" value="">
    <div width="40%" align="center">
    <table width="30%">
    <tr><td class=my_button align="left"><button type="submit" id="button" onClick="return addEntry()"">Add</button></td>
    <td class=my_button align="left"><button type="submit" id="button" onClick="return beforeSubmit()"">Save</button></td></tr>
    </table>
    </div>
    <table align="center" width="90%" style="background-color: #0099cc;" border="10" style="border-collapse:collapse">

    <tr align="left"><td align="left" width="5%">IP ID</td><td align="left" width="30%">IPs</td><td align="left" width="30%">Name:</td><td align="left" width="10%">Active</td><td align="left" width="5%">Delete</td></tr>
    <tr align="left"><td align="left" width="5%"><input type="text" size="5" name="id[1]" id="id[1]" value="1" disabled></td><td><input type="text" size="60" name="name[1]" id="name[1]" value="::1" disabled defaultValue="::1" onChange="itemAdd('name[1]')"></td><td><input type="text" size="60" name="uap[1]" id="uap[1]" value="My" disabled defaultValue="My" onChange="itemAdd('uap[1]')"></td><td width="10%"><input type="checkbox" id="active[1]" name="active[1]" disabled onChange="itemAdd('active[1]')" checked="yes"</input></td><td width="5%"><input type="checkbox" id="delete[1]" name="delete[1]" disabled onChange="itemAdd('delete[1]')"</input></td></tr>
    <tr align="left"><td align="left" width="5%"><input type="text" size="5" name="id[2]" id="id[2]" value="2" disabled></td><td><input type="text" size="60" name="name[2]" id="name[2]" value="127.0.0.1" disabled defaultValue="127.0.0.1" onChange="itemAdd('name[2]')"></td><td><input type="text" size="60" name="uap[2]" id="uap[2]" value="My" disabled defaultValue="My" onChange="itemAdd('uap[2]')"></td><td width="10%"><input type="checkbox" id="active[2]" name="active[2]" disabled onChange="itemAdd('active[2]')" checked="yes"</input></td><td width="5%"><input type="checkbox" id="delete[2]" name="delete[2]" disabled onChange="itemAdd('delete[2]')"</input></td></tr>
    <tr align="left"><td align="left" width="5%"><input type="text" size="5" name="id[3]" id="id[3]" value="3" disabled></td><td><input type="text" size="60" name="name[3]" id="name[3]" value="75.85.144.123" disabled defaultValue="75.85.144.123" onChange="itemAdd('name[3]')"></td><td><input type="text" size="60" name="uap[3]" id="uap[3]" value="My" disabled defaultValue="My" onChange="itemAdd('uap[3]')"></td><td width="10%"><input type="checkbox" id="active[3]" name="active[3]" disabled onChange="itemAdd('active[3]')" checked="yes"</input></td><td width="5%"><input type="checkbox" id="delete[3]" name="delete[3]" disabled onChange="itemAdd('delete[3]')"</input></td></tr>
    </table>
    </form>
    </td>
    </tr>
    </table>
    </div>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator threadi

    (@threadi)

    I don’t know exactly what you mean by

    When the form is placed on line

    ? The form apparently also requires JavaScript, which presumably also plays a role here. What does that look like?

    It would also be interesting to know in which frame it is displayed. Is it in a template, shortcode, widget … ? WordPress may also filter HTML code before output. Therefore, take a look at what HTML code is actually visible in the frontend.

    If you could see it under a link, we could tell you more about it.

    Thread Starter Randem Systems

    (@randem06)

    Hi Threadi,

    Thanks for your reply. This is what I mean:

    On-Line: On a hosted account (VPS Server)

    Local: On the PC using WampServer

    The code I showed was the actual output and is pure HTML (View page source). I cannot give a link to it because it is in the admin section and you will not see it. As far as the javascript it does not matter. I have shown the javascript functions below. It does the same even if I make the the javascript functions completely empty, so the javascript has no effect.. The post still goes to the URL line (https://botbanish-test.com/wp-admin/admin.php?BOTBANISH_BLACKWHITE=Domain+Lists&BOTBANISH_POST_CODE=). On WampServer it posts correctly.

    function beforeSubmit() {

    var allInputs = document.getElementsByTagName("input");
    var allSelects = document.getElementsByTagName("select");

    for(var k = 0; k < allInputs.length; k++) {

    var name = allInputs[k].name;

    if(!isItemChanged(name))
    allInputs[k].disabled = true;
    }

    for(var k = 0; k < allSelects.length; k++) {

    var name = allSelects[k].name;

    if(!isItemChanged(name))
    allSelects[k].disabled = true;
    }

    var botbanish_postcode = document.getElementById("BOTBANISH_POST_CODE");
    var botbanish_user = document.getElementById("user");
    var botbanish_type = document.getElementById("type");
    var botbanish_area = document.getElementById("area");

    var botbanish_checked = document.getElementById("botbanish_checked");
    var botbanish_unchecked = document.getElementById("botbanish_unchecked");
    var botbanish_original = document.getElementById("botbanish_original");

    botbanish_checked.disabled = false;
    botbanish_checked.value = JSON.stringify(items_checked);
    botbanish_unchecked.disabled = false;
    botbanish_unchecked.value = JSON.stringify(items_unchecked);
    botbanish_original.disabled = false;
    botbanish_original.value = JSON.stringify(items_original_checkbox_state);

    botbanish_postcode.disabled = false;
    botbanish_user.disabled = false;
    botbanish_area.disabled = false;
    botbanish_type.disabled = false;
    return true;
    }

    function addEntry() {

    var botbanish_postcode = document.getElementById("BOTBANISH_POST_CODE"); // Post code
    botbanish_postcode.disabled = false;
    botbanish_postcode.value = 'add';
    beforeSubmit();
    return true;
    }
    Thread Starter Randem Systems

    (@randem06)

    Another thing is that even when I use the action=”admin-post.php” the url still goes to the url admin.php?form_parameters. if i use esc_url( admin_url( ‘admin-post.php’ ), it still goes to admin.php instead of admin-post.php

    Moderator threadi

    (@threadi)

    Check whether the form you have written is inside another form. There are many globally defined forms in the backend.

    Thread Starter Randem Systems

    (@randem06)

    That was it! A form inside another form, but it is still strange on why it works in WampServer but not on the VPS. I changed all the logic to the POST instead of the GET and use the custom action for forms which was not working previously. Thanks for your help!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Submit always sends data to URL’ is closed to new replies.