Add specific products to cart when a button is pressed

Im making this website that is basically going to be just a 2 product page and a checkout, and due to its target audience, the idea is to have two images, 2 number boxes under them and just one button to add the products to the cart and then to redirect to the checkout page.

What i imagined is having a form, with a button, that would call a PHP function and would get the value from the number boxes and then programatically add the products to the cart (do i insert this function in functions.php ?). However after some reading i found that i may have to use AJAX to connect the HTML code to the PHP.

Do you have any suggestions? Is my way of thinking flawed?