my question isnt really php specific but all curl posts seem to be in this subforum. i've searched for an answer to this but have come up empty, mostly because i am not sure how to phrase my question. i am also very new to curl and not even sure what i am doing as i am trying to adapt this from someone else's example.

i am trying to submit a webform to login to a site. curl works on the login.php page. however once you log in it goes to an "i agree" page with a checkbox but it is still login.php. here is my code:

curl -k --cookie-jar cookie.txt --referer "$referer" --user-agent "$useragent" -d "login=$user&pass=$pass" -o test.php
data=$(cat "test.php" | grep data | cut -d"\"" -f6)
echo "$data"
curl -k --cookie cookie.txt --referer "$referer" --user-agent "$useragent" -d "i_agree=1&do_agreement=1&data=$data" -o test2.php
i output the results to a file and it looks like curl logs in and gets to the "i agree" part but when it tries to act on the "i agree" part it reloads it or something and is once again working with the login part of login.php instead of the "i agree" part of login.php.

can i combine the two commands? i am really clueless as to how to proceed with this.