submitsave.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. // Check for submission of entered data
  3. if (isset($_POST['submit'])){
  4. if ( ( $nameErr != "") ||
  5. ( $emailErr != "") ||
  6. ( $telErr != "") ||
  7. ( $legalpermissionErr != "" ) ||
  8. ( $languageErr != "") ||
  9. ( $storyErr != "") ||
  10. ( $titleErr != "") ||
  11. ( $authorshipErr != "" ) ) {
  12. if ($nameErr != "") {
  13. echo $nameErr;
  14. }
  15. if ($emailErr != "") {
  16. echo $emailErr;
  17. }
  18. if ($telErr != "") {
  19. echo $telErr;
  20. }
  21. if ($legalpermissionErr != "") {
  22. echo $legalpermissionErr;
  23. }
  24. if ($storyErr != "" ) {
  25. echo $storyErr;
  26. }
  27. if ($titleErr != "" ) {
  28. echo $titleErr;
  29. }
  30. if ($authorshipErr != "") {
  31. echo $authorshipErr;
  32. }
  33. die(' Data is not entered correctly.');
  34. }
  35. else{
  36. $languagename = getlanguage($language);
  37. $to = "lugha@tuvutepamoja.africa";
  38. $subject = "Story Submission";
  39. $txt = "Dear " . $name . ",\n Thanks for your short story submission in " . $languagename . ". Your story has the title:\n" .$title ."\n We have your contact telephone as :\n" . $countryCode . " " . $tel . "\n We will remind you when the translation and evaluation phase begin. 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";
  40. $txt = wordwrap($txt , 70);
  41. $headers = "From: lugha@tuvutepamoja.africa" . "\r\n" . "CC: " . $email ."\r\nContent-Type: text/plain; charset=UTF-8";
  42. mail($to,$subject,$txt,$headers);
  43. echo "<br>";
  44. echo "Thank you for your submission. You should receive an acknowledgement from a human within 1 working day.";
  45. echo "Please restart your web browser if you wish to make another submission.";
  46. echo "<br>";
  47. // Create connection
  48. $conn = mysqli_connect($servername, $username, $password, $dbname);
  49. mysqli_set_charset($conn, "utf8");
  50. // Check connection
  51. if (!$conn) {
  52. die("Database connection failed: " . mysqli_connect_error());
  53. }
  54. $wordsentered = wordcount($story);
  55. $name=mysqli_real_escape_string($conn,$name);
  56. $story=mysqli_real_escape_string($conn,$story);
  57. $title=mysqli_real_escape_string($conn,$title);
  58. $email=mysqli_real_escape_string($conn,$email);
  59. $tel=mysqli_real_escape_string($conn,$tel);
  60. $checked = "no";
  61. $translation = "no";
  62. $translatedfromid = 0;
  63. $sql = "INSERT INTO originalstories (name, legalpermission, email, countryCode, tel, language, title, story, authorship, wordsentered, checked, translation, translatedfromid) VALUES ( '" . $name . "', '" . $legalpermission . "', '" . $email . "', '" . $countryCode . "', '" . $tel . "' , '" . $language . "','" . $title . "', '" . $story . "', '" . $authorship . "', '" . $wordsentered . "', '" . $checked . "', '" . $translation . "', '" . $translatedfromid . "' )";
  64. if (mysqli_query($conn, $sql)) {
  65. echo "New record created successfully";
  66. } else {
  67. echo "Error creating database record, please contact lugha@tuvutepamoja.africa.";
  68. //echo $sql . "<br>" . mysqli_error($conn);
  69. }
  70. mysqli_close($conn);
  71. }
  72. }
  73. ?>