Hi All,
This is kind of hard for me to explain so bear with me:
I'm working on a "Job Request Form". I have a plain HTML form, and when submitted, its contents are passed to a confirmation page, which contains the following script: (this script creates and fills a new text file)
As you can probably see from the last line in the preceding script, there is a redirect to the index.php page, which contains the following script: (this script creates and displays a link for each job that has been created)Code:<?php // Set some variables $filename = 'data/' . $_POST['projName'] . '.txt'; $newevent = $_POST['projName'] . ' | ' . $_POST['stockNum'] . ' | ' . $_POST['dueDate'] . ' | ' ... ; // Create text file and write job data to file $handle = fopen($filename, 'w'); $text = $newevent; fwrite($handle, $text); fclose($handle); header('Refresh: 3; url=index.php'); ?>
All of the form fields in the "job_web_filled.php" form contain variables which allow the form to be filled from the text files. The very top bit of script on this form looks like this:Code:<?php if ($handle = opendir('data/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo '<p><a href="job_web_filled.php">' . $file . '</a></p>'; } } closedir($handle); } ?>
The problem I'm having is that the form is only being filled by the last job in the list. So, each time you click on a link, doesn't matter which one, the information that fills the form belongs to the last job/text file in the list.Code:<?php $dir = "data/"; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $data = file_get_contents('data/' . $file); list($projName, $stockNum, $dueDate, $jobSheetStarted, $toEditing, $toDesign, $layoutStarted, $contactPerson, $layoutBy, $contactPhone, ... $addtlNotes) = explode(" | ", $data); } closedir($dh); } ?>
I can't figure out how to fix this and would really appreciate any help at all.
Thanks in advance!
- Jenn



Reply With Quote
Bookmarks