submittranslationsave.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. // Check for submission of entered data
  3. if (isset($_POST['submit'])){
  4. if ( ( $nameErr != "") ||
  5. ( $emailErr != "") ||
  6. ( $telErr != "") ||
  7. ( $legalpermissionErr != "" ) ||
  8. ( $languagefromErr != "") ||
  9. ( $languagetoErr != "") ||
  10. ( $storyErr != "") ||
  11. ( $titleErr != "") ||
  12. ( $originalidErr != "" ) ||
  13. ( $translatorErr != "" ) ) {
  14. if ($nameErr != "") {
  15. echo $nameErr;
  16. echo "<br>";
  17. }
  18. if ($emailErr != "") {
  19. echo $emailErr;
  20. echo "<br>";
  21. }
  22. if ($telErr != "") {
  23. echo $telErr;
  24. echo "<br>";
  25. }
  26. if ($legalpermissionErr != "") {
  27. echo $legalpermissionErr;
  28. echo "<br>";
  29. }
  30. if ($languagefromErr != "") {
  31. echo $languagefromErr;
  32. echo "<br>";
  33. }
  34. if ($languagetoErr != "") {
  35. echo $languagetoErr;
  36. echo "<br>";
  37. }
  38. if ($storyErr != "" ) {
  39. echo $storyErr;
  40. echo "<br>";
  41. }
  42. if ($titleErr != "" ) {
  43. echo $titleErr;
  44. echo "<br>";
  45. }
  46. if ($translatorErr != "") {
  47. echo $translatorErr;
  48. echo "<br>";
  49. }
  50. if ($originalidErr != "") {
  51. echo $originalidErr;
  52. echo "<br>";
  53. }
  54. die(' Data is not entered correctly.');
  55. }else{
  56. $originallanguagename = getlanguage($languagefrom);
  57. $translatedlanguagename = getlanguage($languageto);
  58. // Get original title
  59. // Create connection
  60. $conn = mysqli_connect($servername, $username, $password, $dbname);
  61. mysqli_set_charset($conn, "utf8");
  62. // Check connection
  63. if (!$conn) {
  64. die("Database connection failed: " . mysqli_connect_error());
  65. }
  66. $sql = "SELECT title FROM stories WHERE primarykey = '".$originalid."'";
  67. $result = mysqli_query($conn,$sql);
  68. $rows = mysqli_num_rows($result);
  69. if ( $rows > 0 ) {
  70. while($row = mysqli_fetch_array($result)){
  71. $originaltitle = $row["title"];
  72. }
  73. }
  74. mysqli_close($conn);
  75. $to = "lugha@tuvutepamoja.africa";
  76. $subject = "Story Translation Submission";
  77. $txt = "Dear " . $name . ",\n Thanks for your submission of a translated short story from " . $originallanguagename . " to " . $translatedlanguagename . ". The title of the story you translated is\n" . $originaltitle . "\nYour translated story has the translated title:\n" . $title ."\n We have your contact telephone as :\n" . $countryCode . " " . $tel . "\n We will remind you when the evaluation phase begins. Should you have any questions, please contact us at \n lugha@tuvutepamoja.africa \n Thanks again for your contribution which is below.\n\n Sincerely,\nThe organizing committee.\n\n" . $story ."\n";
  78. $txt = wordwrap($txt , 70);
  79. $headers = "From: lugha@tuvutepamoja.africa" . "\r\n" . "CC: " . $email ."\r\nContent-Type: text/plain; charset=UTF-8";
  80. mail($to,$subject,$txt,$headers);
  81. echo "<br>";
  82. echo "Thank you for your submission. You should receive an acknowledgement from a human within 1 working day.";
  83. echo " Please restart your web browser if you wish to make another submission.";
  84. echo "<br>";
  85. // Create connection
  86. $conn = mysqli_connect($servername, $username, $password, $dbname);
  87. mysqli_set_charset($conn, "utf8");
  88. // Check connection
  89. if (!$conn) {
  90. die("Database connection failed: " . mysqli_connect_error());
  91. }
  92. $wordsentered = wordcount($story);
  93. $name=mysqli_real_escape_string($conn,$name);
  94. $story=mysqli_real_escape_string($conn,$story);
  95. $title=mysqli_real_escape_string($conn,$title);
  96. $email=mysqli_real_escape_string($conn,$email);
  97. $tel=mysqli_real_escape_string($conn,$tel);
  98. $checked = "no";
  99. $translation = "yes";
  100. $sql = "INSERT INTO stories (name, legalpermission, email, countryCode, tel, language, title, story, authorship, wordsentered, checked, translation, translatedfromid) VALUES ( '" . $name . "', '" . $legalpermission . "', '" . $email . "', '" . $countryCode . "', '" . $tel . "' , '" . $languageto . "','" . $title . "', '" . $story . "', '" . $translator . "', '" . $wordsentered . "', '" . $checked . "', '" . $translation . "', '" . $originalid . "' )";
  101. if (mysqli_query($conn, $sql)) {
  102. echo "New record created successfully";
  103. } else {
  104. echo "Error creating database record, please contact lugha@tuvutepamoja.africa.";
  105. //echo $sql . "<br>" . mysqli_error($conn);
  106. }
  107. mysqli_close($conn);
  108. }
  109. }
  110. ?>