Question: I have a form (bug_List.php) that writes each individual submission into its own text file. All text files are in a folder titled submissions, which

I have a form (bug_List.php) that writes each individual submission into its own text file. All text files are in a folder titled "submissions," which is on the same level as the form file (bug_List.php). bug_List.php also has a table that reads the text files and displays them in a table. Each report has a link ("Details") next to it. The link goes to the BugReport.php page where the individual text files are read and displayed in their own table. Right now, every "Details" link goes to straight to BugReport.php. I would like to write a link that goes to each individual report (text file) and automatically updates for each report (because it has be able to handle future reports). I also need to be able to write mutliple updates over time (i.e. One update is submitted on Monday and another Tuesday) to the individual report files without hard coding a link. The final page (BugReportUpdate.php -- not included below) will append the updates to the specified text file and display an updated table for the report. I can handle if someone can help me figure out how to link to one report at a time and append to the file that was linked to. Again, I cannot specify a specifc file name in the code as I need to be able to deal with future report submissions.

I have included the code I have below (There's a lot as there are 3 differnet files).

////////////////////// bug_List.php////////////////////

/p>

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

<?PHP echo $Title; ?>


Bug List"; echo "

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo " "; //write a loop that will display data from text files $Dir = "submissions"; if (is_dir($Dir)) { $BugReports = scandir($Dir); foreach ($BugReports as $FileName) { if (($FileName != ".") && ($FileName != "..")) { $Report = file($Dir . "/" . $FileName); echo ""; echo ""; echo ""; echo '"; $line_count = count($Report); if($line_count > 7) { echo ""; echo '"; } } } } $folder = "updates"; if(is_dir($folder)) { $UpdateReports = scandir($folder); foreach ($UpdateReports as $UpdateFile) { if(($UpdateFile != ".") && ($UpdateFile != "..")) { $NewItem = file($folder."/".$UpdateFile); echo ""; echo '"; echo ""; echo ""; } } } if(file_exists(preg_match($Dir."/"."/^Report/") == 0)) { echo ""; } else { echo ""; } echo "
Product NameProduct VersionType of HardwareOperating SystemFrequency of OccurrenceProposed Solution

Bug Description:

".htmlentities($Report[0]); echo ''; echo '

Details

'; //this is the link that I would like to call a specific file based on it's "index" position echo "
'; echo ''; echo htmlentities($Report[1]) . "
"; echo '
'; echo htmlentities($Report[2]) . "
"; echo '
'; echo htmlentities($Report[3])."
"; echo '
'; echo htmlentities($Report[4])."
"; echo '
'; echo htmlentities($Report[5])."
"; echo '
'; echo htmlentities($Report[6])."
"; echo "
Update'; echo htmlentities($Report[$line_count - 1]).'
'; echo "
'; echo "Update for ".htmlentities($NewItem[0])."
"; echo "
"; echo htmlentities($NewItem[1])."
"; echo "
There are no bug reports.
Update existing reports as necessary.
"; ?>

New Bug Report

Bug Description*:

Product Name*:

Product Version*:

Type of Hardware*:

Operating System*:

Frequency of Occurrence*:

Proposed Solution*:

Fields marked with an asterisk (*) are required.

////////////////////// BugReportCreate.php////////////////////

<?PHP echo $Title; ?>


Create a New Bug Report

//assign and validate $Description = validateInput($_POST['description'], "Bug Description"); $PName = validateInput($_POST['pName'], "Product Name"); $Version = validateInput($_POST['version'], "Product Version"); $Hardware = validateInput($_POST['hardware'], "Hardware"); $OS = validateInput($_POST['system'], "Operating System"); $Frequency = validateInput($_POST['frequency'], "Frequency"); $Solution = validateInput($_POST['solution'], "Proposed Solution"); if($errorCount > 0) { echo "Please re-enter the information below.
"; redisplayForm($Description, $PName, $Version, $Hardware, $OS, $Frequency, $Solution); } else { //write and save input to text files in a submissions directory $Dir = "submissions"; $DirEntries = scandir($Dir); if(is_dir($Dir)) { if (isset($_POST['save'])) { $SaveString = stripslashes($_POST['description'])." "; $SaveString .= stripslashes($_POST['pName'])." "; $SaveString .= stripslashes($_POST['version'])." "; $SaveString .= stripslashes($_POST['hardware'])." "; $SaveString .= stripslashes($_POST['system'])." "; $SaveString .= stripslashes($_POST['frequency'])." "; $SaveString .= stripslashes($_POST['solution'])." "; $CurrentTime = microtime(); $TimeArray = explode(" ", $CurrentTime); $TimeStamp = (float)$TimeArray[1] + (float)$TimeArray[0]; $SaveFileName = "$Dir/Reports.$TimeStamp.txt"; if(file_put_contents($SaveFileName, $SaveString) > 0) echo "File \"".htmlentities($SaveFileName)."\" successfully saved.
"; else echo "There was an error writing \"".htmlentities($SaveFileName)."\".
"; } } echo "

Bug Description: ".$Description."

"; echo "

Product Name: ".$PName."

"; echo "

Product Version: ".$Version."

"; echo "

Type of Hardware: ".$Hardware."

"; echo "

Operating Software: ".$System."

"; echo "

Frequency of Occurrence: ".$Frequency."

"; echo "

Proposed Solution: ".$Solution."

"; echo '

Return to the bug list.

'; }

//error message to display required field function displayRequired($fieldName) { echo "The field \"$fieldName\" is required.
"; } //AUTHOR NOTE: What to validate for was not specified so I just checked to make sure the //fields weren't empty because the other code took a while to figure out. //validate form input function validateInput($data, $fieldName) { global $errorCount; if(empty($data)) { displayRequired($fieldName); ++$errorCount; $retval = " "; } else { //clean up valid input $retval = trim($data); $retval = stripslashes($retval); } return($retval); } $errorCount = 0; //redisplay form if invalid data is entered function redisplayForm($Description, $PName, $Version, $Hardware, $System, $Frequency, $Solution) { ?>

New Bug Report

Bug Description*:

Product Name*:

Product Version*:

Type of Hardware*:

Operating System*:

Frequency of Occurrence*:

Proposed Solution*:

Fields marked with an asterisk (*) are required.

////////////////////// BugReport.php////////////////////

/p>

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

<?PHP echo $Title; ?>


Bug Reports

"; echo '

'; echo '

Bug Description

'; echo ''.htmlentities($Report[0]).''; echo ''; echo ''; echo '

Product Name

'; echo ''.htmlentities($Report[1]).''; echo ''; echo ''; echo '

Product Version

'; echo ''.htmlentities($Report[2]).''; echo ''; echo ''; echo '

Type of Hardware

'; echo ''.htmlentities($Report[3]).''; echo ''; echo ''; echo '

Operating System

'; echo ''.htmlentities($Report[4]).''; echo ''; echo ''; echo '

Frequency of Occurrence

'; echo ''.htmlentities($Report[5]).''; echo ''; echo ''; echo '

Proposed Solution

'; echo ''.htmlentities($Report[6]).''; echo ''; echo ''; //add an update --- I need to make sure any and all updates will be appended to the specific file called by clicking the details link goes to echo "

Add an update

"; echo '
'; echo '

Bug Decription to be updated*:

'; echo '

Update Info*:

'; echo '

'; echo "
"; echo '

Return to bug list.

'; echo "
"; } } }

?>


As of format('H:i:s'); ?> © by AACC .
All Rights Reserved.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!