• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

php sticky form fields wont update

I have a form which loads its values from a text file. When I update a field and press submit, the text file is updated with the new value but the sticky field still shows the prior value. Can anyone enlighten me as to what I've done wrong? My brain has become mush...

form fields look like this:

<input type="text" name="businessname" id="businessname" <?php stickyfield($SET_BNAME); ?>/>
external config file (php include) looks like this:

function stickyfield($fieldname){
if(isset($fieldname)){echo ' value="'.trim($fieldname).'"'; };
I have ommited the other data but $SET_BNAME refers to the array element im extracting from the text file as follows:

$settingsfile = file(SETTINGS);

for ($i = 0; $i < count($settingsfile); $i++) {
// separate each element and store in a temporary array
$tmp = explode(': ', $settingsfile[$i]);
// assign each element of the temporary array to a named array key
$settingsfile[$i] = array('setting' => $tmp[0], 'value' => $tmp[1]);
$SET_BNAME = trim($settingsfile[0]['value']);
(SETTINGS is defined to text file location)


1. My form input field reads specific line from text file and makes field value (as an example) 'plumbing inc'
2. I change the input field to 'electrician inc' and press submit
3. The specific line on the text file is updated to 'electrician inc', but the form field still says 'plumbing inc'
Fair enough....solved it myself...I put a header location redirect and changed text field code

<input type="text" name="businessname" id="businessname" <?php if (!in_array('businessname', $missing)){stickyfield($SET_BNAME);} ?>/>