Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Form Values

Status
Not open for further replies.

AGNEW2PRG

Technical User
Aug 5, 2003
98
AE
Hi All,

I am in the process of gathering information of printers at various locations. I have created a web form that the user populates and when submitted, it calls a php script that writes to a csv file. This works okay.

When the csv file is written, the user is redirected back to the form to be filled in should he wish to add another printer

What I would like to do is save the user from having to fill in the Company, Branch and Contact details in for every submission. Is there any way I can prepopulate certian fields of the form with the information already submitted on the first submission.

Any help will be appreciated.

Thanks
 
sure

Code:
<?
if (isset($_POST['submit'])){

 // process results
 $printermake=$_POST['printermake'];
 $printerlocationbranch = $_POST['printerlocationbranch'];
 $printerlocationcompany = $_POST['printerlocationcompany'];
 $fh = fopen("somecsvfile.csv", 'a+');
 fwrite ($fh, "$printermake,$printerlocationbranch,$printerlocationcompany");
 fclose($fh);
} else {
 $printermake=$printerlocationbranch=$printerlocationcompany="";
}
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
Printer Make: <input type="text" name="printermake" value="<?=$printermake?>" /><br/>
Company: <input type="text" name="printerlocationcompany" value="<?=$printerlocationcompany?>" /><br/>
Branch: <input type="text" name="printerlocationbranch" value="<?=$printerlocationbranch?>" /><br/>
<input type="submit" name="submit" value="submit" />
</form>
 
You'll have to catch those values and then resend them to the form, and pick them up. In the event they are there, populate the relevant fields with them.

However depending on whether your Form page is the same page as processing the script, or is in another page will be how you can get the values back and populate the fields.

Can you tell us a bit more about your form, and how it is processed?




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top