Search code examples
phpjavascripthtmlrating-system

How should I accomplish my rating script


My webpage has a table where you can select different items. I want to be able to let people rate these. I ran into a problem where I would need to pass a javascript variable to php, and from what I read online isn't the easiest thing. How would you suggest I do this?

The code is stored at 98.214.131.200/index.php and 98.214.131.200/ratings/ratings.php

currently I have functions in ratings.php that allow me to write or read the ratings, but I need the a string from the javascript to identify which item is being rated.


Solution

  • You could pass the rating using a POST request from a form.

    http://www.tizag.com/phpT/forms.php/

    Make sure you correctly sanitize your inputs to avoid SQL injections

    http://www.tizag.com/mysqlTutorial/mysql-php-sql-injection.php