Jump to content

Saving form(checkbox) result into .txt


hahn

Recommended Posts

hi,

 

I'm trying to do a survey using php. And I'm noob to the world of php.

Basically what I'm trying to do here is let people check all the translation for given Chinese sentence.

I'm using checkbox here but I'm stuck in where I have to save the result in a chi.txt file.

 

Below is html code. I'm using POST here, making it send the result to chi.php


<form onsubmit="window.open ('chi2.html')" id="form1" name="form1" method="post" action="chi.php">
  <table width="100%" border="0" cellspacing="10" cellpadding="10">
    <tr>
      <th width="18%" align="left" valign="top" bgcolor="#DDF2FB" scope="col"> </th>
      <td width="1790" align="left"><strong>虽然有关方面已经确认1日失踪的法航空中客车A330-200班机已坠落大西洋,但是搜救行动还在进行中。</strong></td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="0" value="SYS" />
        Systran</strong></td>
      <td align="left">Although however the parties    concerned confirmed that on 1st the missing Air France Airbus A330-200 flight    has crashed Atlantic, but the rescue operation is also carrying on.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="1" value="IMT" />
        IM Translator</strong></td>
      <td align="left">Although it has been confirmed    that the disappearance of the Law on the 1st Air Airbus A330-200 in flight    has crashed the Atlantic, but still in search and rescue operations. </td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="2" value="GOO" />
        Google Translate</strong></td>
      <td align="left">Although it has been confirmed    that the disappearance of the Law on the 1st Air Airbus A330-200 in flight    has crashed the Atlantic, but still in search and rescue operations.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="3" value="BAB" />
        Babylon</strong></td>
      <td align="left">Although it has also been    confirmed missing in the 1st Aviation bus A 330-200 flights have been falling    Atlantic, but also in the search and rescue operations.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="4" value="LEC" />
        LEC</strong></td>
      <td align="left">Although the parties concerned    has already oned 1st confirm to disappear of the air passenger car A330 - 200    flights of Air France have already sink into Atlantic Ocean, search and    rescue the activity to return at in progress.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="5" value="TRC" />
        Transclick</strong></td>
      <td align="left">Although the parties concerned    has already oned 1st confirm to disappear of the air passenger car A330 - 200    flights of Air France have already sink into Atlantic Ocean, search and    rescue the activity to return at in progress.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="6" value="TRL" />
        Translated.net</strong></td>
      <td align="left">Although the parties concerned    already confirmed on 1st is missing in the law aviation the passenger train    A330-200 flight has crashed Atlantic, but search and rescue motion also in    march.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="7" value="TRS" />
        Translution</strong></td>
      <td width="1790" align="left">Although    the parties concerned already confirmed on 1st is missing in the law aviation    the passenger train A330-200 flight has crashed Atlantic, but search and    rescue motion also in carrying on.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="8" value="ALS" />
        APL</strong></td>
      <td width="1790" align="left">Although    the parties concerned already confirmed on 1st is missing in the law aviation    the passenger train A330-200 flight has crashed Atlantic, but search and    rescue action also in carrying on.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="9" value="SDL" />
        SDLfreetranslation</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="10" value="IBM" />
        IBM(Websphere)</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="11" value="GOD" />
        Godict</strong></td>
      <td width="1790" align="left">The    passenger car A330-200 airliner already having fallen from Atlantic Ocean,    but searches in the law aviation disappearing though the parties concerned    already affirms 1st to rescue action as early as in progress. </td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="12" value="PRT" />
        Promt</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="13" value="LUC" />
        Lucy(Translandium)</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="14" value="LIN" />
        Linguatec</strong></td>
      <td width="1790" align="left">The    passenger car A330-200 airliner already having fallen from Atlantic Ocean,    but searches in the law aviation disappearing though the parties concerned    already affirms 1st to rescue action as early as in progress.</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="15" value="GRA" />
        GramTrans</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="16" value="TRI" />
        Trident</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="17" value="SUN" />
        Sunda(Seram)</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="18" value="YOU" />
        Youdao</strong></td>
      <td align="left">Although concerned has    confirmed the 1st missing airbus A330-200 air flight across the Atlantic, but    already falling search and rescue operations are still in progress</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="19" value="AMI" />
        Amikai</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="20" value="MGG" />
        MagicalGate</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="21" value="WTS" />
        WebTranSmart</strong></td>
      <td align="left">N/A</td>
      </tr>
    <tr>
      <td align="left" valign="top" bgcolor="#DDF2FB"><strong>
        <input type="checkbox" name="chi[]" id="22" value="TRM" />
        TranSmart</strong></td>
      <td align="left">N/A</td>
      </tr>
  </table>
  <br />
  <p style="text-align:right">
      <input type="submit" name="submit" id="submit" value="Continue" />
  </p>
</form>

 

When clicked submit button, chi.php is supposed to log checked item into chi.txt file.

Please see below chi.php file.

 

<?php
$data = $_POST['radio'];

$file = "chi.txt";
$save = "$data\r";
$fp = fopen($file, "a") or die("Couldn't open $file for login!");
fwrite($fp, $save) or die("Couldn't open new page!");

fclose($fp);
echo "Proceed to newly open page.";

$result_array = $_POST['chi'];
for ($i=0; $i<count($result_array); $i++) {
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.