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?
Asked
Active
Viewed 1,864 times
1
-
this is probably helpful http://stackoverflow.com/questions/19235872/how-to-disable-javascript-function-calls-from-the-browser-console – mudin Feb 10 '17 at 11:09
-
@imudin07 by the way is it even possible to submit it multiple times by just writing a loop in console? – PVP Feb 10 '17 at 11:12
-
If you don't prevent it, it is possible – mudin Feb 10 '17 at 11:15
-
I remember I tired to check my own project in this way, it worked – mudin Feb 10 '17 at 11:16
-
which line is it? you have one input tag, it should be [0] – mudin Feb 10 '17 at 11:19
-
No, actually I have two on the same page . The first one is for other purpose. – PVP Feb 10 '17 at 11:22
-
@imudin07 Without loop it worked fine but when I surround these two statements with a loop it just can't work – PVP Feb 10 '17 at 11:24
-
Where is your code? Can U show again? – mudin Feb 10 '17 at 11:38
-
@imudin07 `for(var i=0;i<1000;i++){ document.getElementById("post").innerHTML = "hattttttt"; document.getElementsByTagName("input")[1].click(); }`The thing is when the loop done with its first iteration the page gets reloaded after submitting the post . That is why it is working only for one time. – PVP Feb 10 '17 at 11:43
-
@imudin07 Is there anything we can do to make it run for multiple times?? – PVP Feb 10 '17 at 11:44
-
It depends on browsers, they don't allow for security risk – mudin Feb 10 '17 at 11:48
-
But I am curious about error – mudin Feb 10 '17 at 11:49
-
It is working here https://jsfiddle.net/411488ps/ – mudin Feb 10 '17 at 11:51
-
Is it working at least once using loop? – mudin Feb 10 '17 at 11:55
-
@imudin07 yes it is working only once. – PVP Feb 10 '17 at 12:15
-
Then don't reload the page, try to use ajax request – mudin Feb 10 '17 at 12:20
1 Answers
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