0
I am trying to submit data to a form at work. I suspect that my naive approach doesn't work because of "technology" in the page that interferes with it. Basically, the webpage (sorry I cannot link to it here, it is not public) has
<form action="login.php" method="get" name="LogIn" class="form-signin">
and then several inputs like
<input type="text" class="form-control" id="docIdent" name="docIdent" placeholder="@" required>
so I am trying the following cURL command:
curl -d "docIdent=WHATEVER" -d "type=WHATEVER" -d "comment=" URL
where the three pieces of data seem to be needed were obtained by: 1. Downloading the .html. 2. Changing the form method from "post" to "get" and opening it in a browser. 3. Filling the form and submitting (got a "page not found" error, of course, but the new URL had all that data, including the empty 3rd field).
Well, it doesn't work (I get back the same login page, and I can check that there has been no login at the time I try). I don't know much about these things but I suspect it can be some other code not in the page: there is
<script src="dist/js/bootstrap.min.js"></script>
<script src="dist/js/jquery-3.4.1.min.js"></script>
<script src='js/fns.js'></script>
and of course the "login.php" in the form opening. From many other posts, my syntax seems correct; is there any hope for an automatic login (the type of bash script that I will put in cron, like the one-liner I am trying)? Thanks.
Can you check the actual form submit data using your browser's DevTools, this time without changing the form method or the page's origin in any way? – user1686 – 2019-09-19T10:20:19.190
I'm not sure I'm doing it right, but I found a "Request body" area where I see
Content-Type: application/x-www-form-urlencoded Content-Length: 49 docIdent=WHATEVER&type=WHATEVER&comment=
. Could that encoding be a clue? – David Sevilla – 2019-09-19T10:34:45.580Can you also use
curl -v ...
to check at what is being sent in the second case and compare with the browser? Note that the "type" is not a form field; it is an HTTP header. – user1686 – 2019-09-19T11:39:36.950Ok, so I tried
-v
and got among other things: `> User-Agent: curl/7.64.0` which to me means that with cURL I am sending the same as with Firefox... – David Sevilla – 2019-09-19T11:40:18.010
My last attempt has been
curl -F "type=application/x-www-form-urlencoded" -F "docIdent=WHATEVER" -F "type=WHATEVER" -F "comment=" URL
, not good; also tried changing all the -F to -d, same thing. All I get back is the login page, and I can see in some other way that I didn't make the login. – David Sevilla – 2019-09-24T14:26:27.670