submitevaluation.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <body>
  5. <?php include 'submitdatabaseinfo.php';?>
  6. <?php
  7. function clean_input($data) {
  8. $data = trim($data);
  9. $data = stripslashes($data);
  10. $data = htmlspecialchars($data);
  11. return $data;
  12. }
  13. $comment = $_POST['comment'];
  14. $grammarandspelling = $_POST['grammarandspelling'];
  15. $themeandplot = $_POST['themeandplot'];
  16. $style = $_POST['style'];
  17. $culturalrelevance = $_POST['culturalrelevance'];
  18. $overallimpression = $_POST['overallimpression'];
  19. $id = $_POST['id'];
  20. $voterid = $_POST['voterid'];
  21. $comment = clean_input($comment);
  22. $grammarandspelling = clean_input($grammarandspelling);
  23. $themeandplot = clean_input($themeandplot);
  24. $style = clean_input($style);
  25. $culturalrelevance = clean_input($culturalrelevance);
  26. $overallimpression = clean_input($overallimpression);
  27. $voterid = clean_input($voterid);
  28. // Create connection
  29. $conn = mysqli_connect($servername, $username, $password, $dbvotes);
  30. // Check connection
  31. if (!$conn) {
  32. die("Database connection failed: " . mysqli_connect_error());
  33. }
  34. mysqli_set_charset($conn, "utf8");
  35. $comment=mysqli_real_escape_string($conn,$comment);
  36. $grammarandspelling=mysqli_real_escape_string($conn,$grammarandspelling);
  37. $themeandplot=mysqli_real_escape_string($conn,$themeandplot);
  38. $style=mysqli_real_escape_string($conn,$style);
  39. $culturalrelevance=mysqli_real_escape_string($conn,$culturalrelevance);
  40. $overallimpression=mysqli_real_escape_string($conn,$overallimpression);
  41. $voterid=mysqli_real_escape_string($conn,$voterid);
  42. $id=mysqli_real_escape_string($conn,$id);
  43. $sql = "INSERT INTO votes ( voterid, storyid, comment, grammarandspelling,
  44. themeandplot, style, culturalrelevance,
  45. overallimpression)
  46. VALUES ( '" .$voterid. "','" .$id. "','" .$comment. "',
  47. '" .$grammarandspelling. "','" .$themeandplot. "',
  48. '" .$style. "','" .$culturalrelevance. "',
  49. '" .$overallimpression. "')";
  50. if (mysqli_query($conn, $sql)) {
  51. echo "Your evaluation has been successfully recorded";
  52. } else {
  53. echo "Error recording your evaluation, please contact lugha@tuvutepamoja.africa.";
  54. //echo $sql . "<br>" . mysqli_error($conn);
  55. }
  56. mysqli_close($conn);
  57. exit();
  58. ?>
  59. </body>
  60. </html>