#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    155
    Rep Power
    10

    Form submission would not work correctly


    Hi there,

    I got a special problem which is caused by several forms being displayed on a page by ajax.

    Now each of these forms has the same input fields and is processed by the same script. This is how such a form would look alike:

    PHP Code:
    form onSubmit="ajaxRequest('ajax.support.php\, 'POST', '', 'supportAnswer', ['notification'], ['/images/ajaxLoader.gif']); return false;" method="post" enctype="application/x-www-form-urlencoded" name="supportAnswer"> <div class="row3 clearfix"> <div class="sender">Antworten:</div> <div class="message" style="margin-top:0px;margin-bottom:0px;padding-right:0px;padding-left:0px;"><textarea name="message" style="width:491px;height:140px;border:0px;padding:5px;"/></textarea></div> </div> <p style="clear:both;padding:9px"></p> <div class="text clearfix"><div class="right"><input type="hidden" name="id" value="211" /><input type="hidden" name="postId" value="1356" /><input type="hidden" name="do" value="sendAnswer" /><button type="submit" style="width:144px; height:25px; vertical-align:top;">Senden</button></div></div> </form

    Now the problem I have is, that if there is e.g. 3 forms displayed, no matter which form I hit the submit button it seems that all the time there is sent every field in EVERY form (and not just the one i submit)...

    To give you an example e.g. firebug would show that as being sent by POST:
    do sendAnswer
    do sendAnswer
    do sendAnswer
    do sendAnswer
    do sendAnswer
    id 199
    id 211
    id 210
    id 209
    id 212
    message
    message Testmessage
    message
    message
    message
    postId 1306
    postId 1356
    postId 1349
    postId 1348
    postId 1359


    Can anyone explain to me how this happens? And more important how I can prevent it? Just to say that forehand, I cannot name the fields in each form a different way since these are fields for the same kinda process that is done by ajax.support.php

    Would be thankful for any help I can get.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    we need the definition of ajaxRequest. Obviously this function doesn't fetch the values correctly. Could be a selector issue or something, but we can't tell without the exact code.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo