123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- // Check for submission of entered data
- if (isset($_POST['submit'])){
- if ( ( $nameErr != "") ||
- ( $emailErr != "") ||
- ( $telErr != "") ||
- ( $legalpermissionErr != "" ) ||
- ( $languagefromErr != "") ||
- ( $languagetoErr != "") ||
- ( $storyErr != "") ||
- ( $titleErr != "") ||
- ( $originalidErr != "" ) ||
- ( $translatorErr != "" ) ) {
- if ($nameErr != "") {
- echo $nameErr;
- echo "<br>";
- }
- if ($emailErr != "") {
- echo $emailErr;
- echo "<br>";
- }
- if ($telErr != "") {
- echo $telErr;
- echo "<br>";
- }
- if ($legalpermissionErr != "") {
- echo $legalpermissionErr;
- echo "<br>";
- }
- if ($languagefromErr != "") {
- echo $languagefromErr;
- echo "<br>";
- }
- if ($languagetoErr != "") {
- echo $languagetoErr;
- echo "<br>";
- }
- if ($storyErr != "" ) {
- echo $storyErr;
- echo "<br>";
- }
- if ($titleErr != "" ) {
- echo $titleErr;
- echo "<br>";
- }
- if ($translatorErr != "") {
- echo $translatorErr;
- echo "<br>";
- }
- if ($originalidErr != "") {
- echo $originalidErr;
- echo "<br>";
- }
- die(' Data is not entered correctly.');
- }else{
- $originallanguagename = getlanguage($languagefrom);
- $translatedlanguagename = getlanguage($languageto);
- // Get original title
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- mysqli_set_charset($conn, "utf8");
- // Check connection
- if (!$conn) {
- die("Database connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT title FROM stories WHERE primarykey = '".$originalid."'";
- $result = mysqli_query($conn,$sql);
- $rows = mysqli_num_rows($result);
- if ( $rows > 0 ) {
- while($row = mysqli_fetch_array($result)){
- $originaltitle = $row["title"];
- }
- }
- mysqli_close($conn);
- $to = "lugha@tuvutepamoja.africa";
- $subject = "Story Translation Submission";
- $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";
- $txt = wordwrap($txt , 70);
- $headers = "From: lugha@tuvutepamoja.africa" . "\r\n" . "CC: " . $email ."\r\nContent-Type: text/plain; charset=UTF-8";
- mail($to,$subject,$txt,$headers);
- echo "<br>";
- echo "Thank you for your submission. You should receive an acknowledgement from a human within 1 working day.";
- echo " Please restart your web browser if you wish to make another submission.";
- echo "<br>";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- mysqli_set_charset($conn, "utf8");
- // Check connection
- if (!$conn) {
- die("Database connection failed: " . mysqli_connect_error());
- }
- $wordsentered = wordcount($story);
- $name=mysqli_real_escape_string($conn,$name);
- $story=mysqli_real_escape_string($conn,$story);
- $title=mysqli_real_escape_string($conn,$title);
- $email=mysqli_real_escape_string($conn,$email);
- $tel=mysqli_real_escape_string($conn,$tel);
- $checked = "no";
- $translation = "yes";
- $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 . "' )";
- if (mysqli_query($conn, $sql)) {
- echo "New record created successfully";
- } else {
- echo "Error creating database record, please contact lugha@tuvutepamoja.africa.";
- //echo $sql . "<br>" . mysqli_error($conn);
- }
-
- mysqli_close($conn);
-
- }
- }
- ?>
|