How to make an additional field in the comments, for example, on the left side will be the question: "How much is 1 + 1?" and a slightly more correct field for entering an answer, if the user answers 1, then the comment after clicking on the standard "send comment" button is not added, if 2, then the comment is added?

I understand the process itself. Create a data entry field:

Сколько будет 1+1? <input type="text" name="name"> 

Then we write the condition:

 <? if( $_POST['name'] == '2' ){ echo '<input class="floatl" name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /> <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />'; } else{ echo '<h1>Не правильно!</h1>'; } ?> 

In this case, a button should appear to add a comment if the number is entered correctly, but something is wrong here, because button does not appear.

  • And you post'om just send the data? - ling
  • ling, get'om also tried ... - nick777

4 answers 4

uh ... here the only problem is that the additional field appears after the form has been loaded and the "POST" is not validated. Make the same field, just display it at the right time, changing, say, the css-property display. Then everything will be fine.

    I assume that you have a button, but it has the style float1. Give the css code for float1. Perhaps it is all the catch - you just can not see it, but it is on the form.

    PS: On the other hand, do you think it is convenient for the user to double-click on add a comment? Is it possible to check and immediately write a comment in the database?)

    • If you remove the check and question, then everything is displayed normally. > Is it possible to check and immediately write a comment in the database? I wanted to do that, but I don’t know how ... - nick777

    ling, get'om also tried ...

    Get'om just will not work. Plus, value="<?php echo $id; ?>" Replace with value="'.$id.'" , But it turns out that your php block closes too early.

    • ling did not help. - nick777
    • Then print_r($_POST); . If it writes Array( ) , then the form is not submitted. - ling

    why don't you do it in javascript and until the correct value is entered, the submit button is kept inactive for clicks .. there will be maximum 20 lines of code .. this will save you and users from duplication, especially if after incorrectly entered values ​​you do not substitute the entered user data into place ...