1

Actually in my application i have two input tags one is textarea and other is sort of button to submit it to the database. I want to ask how can I just write a loop in the console and submit the post to the database multiple times. Is it really possible if it is then how can i prevent somebody to do it?

PVP
  • 165
  • 2
  • 10

1 Answers1

0

The answer is Yes, you can submit. There is an example:

<div id='post'></div>
<input type=button>
<input type=button onclick="test()">

<script>
  function test() {
    $.get('https://fiddle.jshell.net/echo/js/?js=hello%20world!', function(data) {
      document.getElementById("post").innerHTML += data;
    });
  }

</script>

Try to call test() function in loop or for(var i=0;i<1000;i++){ document.getElementsByTagName("input")[1].click(); } in browser console and check network, you can see multiple requests and post div is updated

https://jsfiddle.net/411488ps/3/

If you want to prevent it, you have to do something in server side. You can't trust anything sent to the server from the client. You must implement checks at the server end to rate-limit (or just limit), validate, etc., because people can send you any information they like (they don't even have to be using a web browser to do it). Also check this http://www.queness.com/post/16151/disable-javascript-console-in-browsers

mudin
  • 2,672
  • 2
  • 17
  • 45