Skip to content
Advertisement

Prevent users from changing amount charged on payment page

I am trying to integrate payment gateway on my website. There are three courses each having different prices. I am passing the value of the amount and package to form.php and i have made the input fields to readonly but the user can still change the amount in inspect element and make it 0 and pass on the value and get the course for free. How can i stop user from changing the value? or is there any other way to pass the value? or encrypt it and then decrypt it again?

here is my code index.php

JavaScript

form.php

JavaScript

form_process.php

JavaScript

success.php

JavaScript

Advertisement

Answer

Never let the user send the price. Each course has an ID. Let’s assume this:
course 1, has ID = 1, price = 499, name = 2-Days Classroom Training
course 2, has ID = 2, price = 999, name = 4-Days Classroom Training

On your payment page, inside <forms> send only course_id = X.

On the PHP script which receives the request you know that course_id = X has price = Y… This is the price you will charge.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement