Add list item every time i click submit

后端 未结 4 1458
温柔的废话
温柔的废话 2021-01-16 23:55

I want a script which will echo a text from a form to a div tag every time i click the submit button.

i was able to do that in no time but i want the text to still b

4条回答
  •  误落风尘
    2021-01-17 00:23

    You would need to keep adding to a session variable and best to use an array.

    Like so;

     0){
       // add text to session array and escape for security
       $_SESSION['text'][] = htmlspecialchars($_POST['text'], ENT_QUOTES);
    }
    
    ?>
    
    
    
    Name:

    Edit: This only works for the current session, if you want to come back later and see the same list. You would need to store the values somewhere like a database.

提交回复
热议问题