This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Multilanguage identical forms data processing and saving


  1. tbenko
    Member

    I would like to create a form in several languages with the same data fields. Can the data from this forms be saved somehow in just one table, so I do nat have to collect them from x different tables?
    I'll put an example to be more specific: I have two forms, an english and a hungarian, collecting the same kind of data. The only difference between is the language. But the data collected needs to be processed as a single bunch of records, not two or more separate record tables.
    Any suggestions? Thanks in advance.

    Posted 15 years ago #
  2. redityo

    Hi,

    You can still use 1 form in 2 languages with little modification to machform files, so the data will be stored in one table. For example your form language are "English" and "France", to do so try to follow this steps :

    1. Rename "includes/language.php" to "includes/language-en.php" and put "language-fr.php" as "French" language file.
    2. Create a "language.php" file in "includes" folder and put this code in there :

    <?php
    /******************************************************************************
     MachForm
    
     Copyright 2007 Appnitro Software. This code cannot be redistributed without
     permission from http://www.appnitro.com/
    
     More info at: http://www.appnitro.com/
     ******************************************************************************/
    	@session_start();
            $language_id = 'en';
    
    	if (!empty($_GET['lang'])) {
    		$language_id = $_GET['lang'];
    	}
    
    	switch ($language_id){
    		case 'fr' : require('language-fr.php');break;
    		default: require('language-en.php');break;
    	}		
    
    ?>

    3. Give extra GET variable to your url. For example you call the form with this embed code:

    <iframe height="352" allowTransparency="true"
    frameborder="0"
    scrolling="no"
    style="width:100%;border:none"
    src="http://www.yourdomain.com/machform/embed.php?id=50"
    title="Untitled Form">
    <a href="http://www.yourdomain.com/machform/view.php?id=50" title="Untitled Form">
    Untitled Form
    </a>
    </iframe>

    change embed code to be like this, to get "France" language

    <iframe height="352" allowTransparency="true"
    frameborder="0"
    scrolling="no"
    style="width:100%;border:none"
    src="http://www.yourdomain.com/machform/embed.php?id=50&lang=fr"
    title="Untitled Form">
    <a href="http://www.yourdomain.com/machform/view.php?id=50" title="Untitled Form">
    Untitled Form
    </a>
    </iframe>

    MachForm Support

    Posted 15 years ago #
  3. tbenko
    Member

    Thanks for your response, however this sollution is not quite enough, because does not cover Form translation. Whenever I create a form, I add labels and explanations, form name and other info to the form. This info will not be translated with the sollution above.
    Any new suggestions?

    Posted 15 years ago #
  4. tbenko
    Member

    Instead coludn't we save somehow a form's data as it were an other form's data? Let's say saving the french form data to the english form's records? So this way all the records go to one place.

    Posted 15 years ago #
  5. yuniar

    Sorry, this one won't be possible. Each form has its own table and can't be merged.


    MachForm Founder

    Posted 15 years ago #
  6. mkrakowiak
    Member

    It happens that I need a similar solution and also in both French and English. I think you can create two seperate forms and then pull out data from them by using some PHP and MySQL code to display it on the results page.

    Posted 15 years ago #
  7. tbenko
    Member

    Yes, I was thinking of that as a backup option and last resource...
    I was hoping that I will get a sollution like a form id replacement at the saving stage of the code... so one of the forms will be saved in the data table of the other form...

    Seems to me that i will have to search the code, maybe I will have some luck and find the saving spot, where the query is put together...

    Posted 15 years ago #
  8. mkrakowiak
    Member

    tbenko, if you still need the code, let me know and I can send it to you. I can also post it here if anyone may find it useful.

    Posted 15 years ago #
  9. yuniar

    feel free to post it here :-)


    MachForm Founder

    Posted 15 years ago #
  10. mkrakowiak
    Member

    OK, here it goes:

    <!-- What the code does, it queries two identical (set up for bilingual forms)
    tables, pulls out data from specific fields (element_1, element_2 etc. but you
    can figure out the column names by browsing your database through phpMyAdmin
    for example) and sorts it. To see the code in action,
    go to http://dignityforall.ca/en/campaign-supporters -->
    
    <?php
    mysql_connect("HOST", "DB_USER", "PASSWORD") or
    die('Cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("DB_NAME") or die(mysql_error());
    
    // select organizations only - element_3 is checked whether a user signed on
    as individual or for an organization
    $query_organizations = "SELECT element_2 FROM ap_form_1 WHERE element_3 = '2'
    UNION SELECT element_2 FROM ap_form_2 WHERE element_3 = '2' ORDER BY element_2 ASC";
    
    // select names and applicable organizations
    $query_individuals = "SELECT CONCAT_WS(', ', element_4, element_2) AS name
    FROM ap_form_1 WHERE element_3 = '1' UNION SELECT CONCAT_WS(', ', element_4,
    element_2) AS name FROM ap_form_2 WHERE element_3 = '1' ORDER BY name ASC";
    
    $result_organizations = @mysql_query($query_organizations);
    $num_organizations = mysql_num_rows($result_organizations); // counter
    $result_individuals = @mysql_query($query_individuals);
    $num_individuals = mysql_num_rows($result_individuals); // counter
    
    echo '<strong>'.$num_organizations.' groups and '.$num_individuals.'
    individuals have signed our petition.</strong>
    ;
    
    if ($num_organizations > 0) { // If it ran OK, display the records.
    
    	echo "<strong>$num_organizations organizations have signed our petitions:
    </strong><ol>";
    
    	// Fetch and print all the records.
    	while ($row = mysql_fetch_array($result_organizations)) {
    		echo '<li>' . $row[element_2] . '</li>';
    	}
    
    	echo '</ol>';
    
    	mysql_free_result ($result_organizations);  //Free up the resources.	
    
    } else { // If it did not run OK.
    	echo 'No organization have signed our petition yet.
    ';
    }
    
    if ($num_individuals > 0) { // If it ran OK, display the records.
    
    	echo "<strong>$num_individuals individuals have signed our petition:
    </strong><ol>";
    
    	// Fetch and print all the records.
    	while ($row = mysql_fetch_array($result_individuals)) {
    		echo '<li>' . $row[name] . '</li>';
    	}
    
    	echo '</ol>';
    
    	mysql_free_result ($result_individuals);  //Free up the resources.	
    
    } else { // If it did not run OK.
    	echo 'No one have signed our petition yet.
    ';
    }
     ?>
    Posted 15 years ago #
  11. gillesp
    Member

    tbenko,

    did you found a solution to your problem? I have the same. Thanks

    Posted 15 years ago #

RSS feed for this topic

Reply