Jump to content

Need help with doing this part of the file


tahj

Recommended Posts

The radio buttons for each question should consist of the following options: No Opinion, Poor, Fair, Good, or Excellent. Separate text files should store the results of a single survey. Include a View Past Survey Results button on the main survey page that displays a list of past survey results.

 

We already have the radio buttons part. I am not sure how to make a MySQL file that will create a separate text file for each entry.

 

Here is the php file we currently have:

 

<!DOCTYPE html PUBLIC "-w3c/DTD xhtml 1.0 Transitional//EN"

"http://w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

 

<head><title>Airline Survey</title></head>

<body>

<?php

    $Flight_In = $_POST["Flight"];

    $Date_In = $_POST["Date"];

    $Time_In = $_POST["Time"];

    $Friendliness_In  = $_POST["FriendlinessRad"];

    $Space_In = $_POST["SpaceRad"];

    $Comfort_In = $_POST["ComfortRad"];

    $Cleanliness_In = $_POST["CleanlinessRad"];

    $Noise_In = $_POST["NoiseRad"];

   

    echo "$Date_In";

    $File = "Survey.txt";

    file_put_contents ($File, $Flight_In);

 

   

?>

</body>

</html>

Link to comment
Share on other sites

  • 3 weeks later...

Ok, this is what I got so far:

 

Here is the HTML part of the program:

<!DOCTYPE html PUBLIC "-w3c/DTD xhtml 1.0 Transitional//EN"

"http://w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

 

<head><title>Airline Survey</title></head>

<body>

<form action="Project.php" method="POST">

    <table border="2" bgcolor= "#FFFF99">

        <tr>

            <td colspan="3" align="center"><h2>AIRLINE SURVEYS</h2></td>

        </tr>

        <tr>

            <td>FLIGHT #: <input type="text" name="Flight">

            Date: <input type="text" name="Date">

            TIME: <input type="text" name="Time"></td>

        </tr>

        <tr>

            <td colspan="3">a. Friendliness of customer staff<br />

                <input type ="radio" name="FriendlinessRad" value="Excellent">Excellent<br />

                <input type ="radio" name="FriendlinessRad" value="Good">Good<br />

                <input type ="radio" name="FriendlinessRad" value="Fair">Fair<br />

                <input type ="radio" name="FriendlinessRad" value="Poor">Poor<br />

                <input type ="radio" name="FriendlinessRad" value="No Opinion">No Opinion<br />

                </td>

        </tr>

        <tr>

            <td colspan="3">b. Space for luggage Storage<br />

                <input type ="radio" name="SpaceRad" value="Excellent">Excellent<br />

                <input type ="radio" name="SpaceRad" value="Good">Good<br />

                <input type ="radio" name="SpaceRad" value="Fair">Fair<br />

                <input type ="radio" name="SpaceRad" value="Poor">Poor<br />

                <input type ="radio" name="SpaceRad" value="No Opinion">No Opinion<br />

                </td>

        </tr>

        <tr>

          <td colspan="3">c. Comfort of seating<br />

                <input type ="radio" name="ComfortRad" value="Excellent">Excellent<br />

                <input type ="radio" name="ComfortRad" value="Good">Good<br />

                <input type ="radio" name="ComfortRad" value="Fair">Fair<br />

                <input type ="radio" name="ComfortRad" value="Poor">Poor<br />

                <input type ="radio" name="ComfortRad" value="No Opinion">No Opinion<br />

                </td>

        </tr>

        <tr>

          <td colspan="3">d. Cleanliness of aircraft<br />

                <input type ="radio" name="CleanlinessRad" value="Excellent">Excellent<br />

                <input type ="radio" name="CleanlinessRad" value="Good">Good<br />

                <input type ="radio" name="CleanlinessRad" value="Fair">Fair<br />

                <input type ="radio" name="CleanlinessRad" value="Poor">Poor<br />

                <input type ="radio" name="CleanlinessRad" value="No Opinion">No Opinion<br />

                </td>

        </tr>

        <tr>

          <td colspan="3">e. Noise level of aircraft<br />

                <input type ="radio" name="NoiseRad" value="Excellent">Excellent<br />

                <input type ="radio" name="NoiseRad" value="Good">Good<br />

                <input type ="radio" name="NoiseRad" value="Fair">Fair<br />

                <input type ="radio" name="NoiseRad" value="Poor">Poor<br />

                <input type ="radio" name="NoiseRad" value="No Opinion">No Opinion<br />

                </td>

        </tr>

        <tr>

            <td colspan="3" align="center"><input type="submit" value="Submit">&nbsp &nbsp<input type="reset" value="Clear Form">&nbsp &nbsp<input type="button" value="View Past Survey"></td>

        </tr>

</form>

</body>

</html>

 

 

This part is the php/mySQL coding that needs some work:

<!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Strict //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml -strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

 

<head><title></title></head>

<body>

    <?php

      //connecting to the MySQL server

      $connectdB = @mysqli_connect("localhost", "flights", "security") or die ("<h2>No Connection established</h2>" . "Error code ". mysqli_connect_errno($connectdB) . ": ". mysqli_connect_error($connectdB) . "</p>");

      echo "<p>Connection established</p>";

 

      //selecting the database cs609students

      $dbname = "flightsurvey";

     

      $selectdb = @mysqli_select_db($connection,$dbname) or die ("<p>Database not selected. " . " The error number " . mysqli_errno($connection) . " means " . mysqli_error($connection) . "</p>");

  echo "<p>Database flightsurvey has been selected.</p>";

 

 

//inserting records into the file

  $insertsurvey = "insert into survey_table values ("Flight #", 'United Airlines', "Date")";

  $insertresult = mysqli_query($connectdB, $insertsurvey) or die ("<p>Please rate your recent flight experience");

        echo "<p>A record has been added to its own file";

  $afile = "survey.txt";

 

  file_put_contents($dbname,$afile);

 

//closing the file

    fclose($afile);

 

file = file_get_contents("survey.txt");

Echo $afile;

 

 

 

?>

</body>

</html>

 

I need help with programming it to create a new file every time a new survey is made when someone clicks the submit button, and how to view past submitted surveys. Is what I have so far correct?

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.