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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoid Redundancy

Status
Not open for further replies.

focus72050

Programmer
May 6, 2005
3
US
I have a signature log for a building that i would like to do in php. i have about 20 fields that i accept through post. The problem is 15 of those fields are going to always be the same for each session, but i dont want the user to have to type in that information 'n' times, i want them to type it in only once but that information goes into the sql database for each entry that they enter for that session. Can anyone help me please, i am really stomped.
 
Use hidden fields and have the values hard coded.
Code:
<input name="hiddenfield1" type="hidden" value="<?php echo $_SESSION['hiddenfield1variable']; ?>">

If you are passing a variable into the field, you could do it like that, if it is a session variable, or just replace the PHP code with a fixed variable:
Code:
<input name="hiddenfield1" type="hidden" value="sausages">

I hope this is of some help./


| Feedback is always appreciated as this will help to further our knowledge as well |
 
You already used the correct idea - "SESSION".
Create a PHP session by calling session_start() at each page.
On the page that recevies the POST from the form set the $_POST values into $_SESSION.
On subsequent pages reuse the $_SESSION array to fill the required fields.

As a note:
Repeating redundant information in each record usually is poor database design. I would consider externalizing the redundant data into a table with a foreign key.
 
i am a newbie at this and logically what u have to say makes alot of sense, is it possible you could explain to me what you mean and how could i go about it
re:
As a note:
I would consider externalizing the redundant data into a table with a foreign key.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top