Results 1 to 2 of 2

Thread: php sticky form fields wont update

  1. #1
    Join Date
    Aug 2009
    Posts
    88

    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? It's far too late in the evening and my brain has become mush...

    form fields look like this:

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

    Code:
    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:

    Code:
    $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)



    HOW IT WORKS/DOESNT WORK:


    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'
    Web Design Blackpool, UK - Sign up to my free monthly newsletter for web tips and advice
    One Page Web Design

  2. #2
    Join Date
    Aug 2009
    Posts
    88
    Fair enough....solved it myself...I put a header location redirect and changed text field code

    Code:
    <input type="text" name="businessname" id="businessname" <?php if (!in_array('businessname', $missing)){stickyfield($SET_BNAME);} ?>/>
    Web Design Blackpool, UK - Sign up to my free monthly newsletter for web tips and advice
    One Page Web Design

Similar Threads

  1. Creating Required Fields for a Contact Form
    By Bonanza84 in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 02 Apr 2009, 11:03 AM
  2. PHP Form Validation ???
    By j4mes_bond25 in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 25 May 2006, 05:17 AM
  3. Form processing question (PHP preferred))
    By Endante in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 09 Mar 2006, 07:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •