Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6330441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:52:15+00:00 2026-05-24T17:52:15+00:00

Hi just looking for some direction, I have a HTML form which has several

  • 0

Hi just looking for some direction, I have a HTML form which has several fields and basically what I am wanting to do is save the data entered from the form to a PHP config file and also have the ability to edit the saved data by accessing and submitting the form again. I would prefer to do this without the use of a database.

So here’s an example:

<form method="post" name="config_form">
<div id="field">
<label>Keywords</label>
<br />
<input type="text" name="keyword">
</div>

<br />

<select name="color">
<option value="green">Green</option>
<option value="orange">Orange</option>
<option value="blue">Blue</option>
<option value="red">Red</option>
</select>

</form>

So the user enters ‘computer’ as the keyword and selects the color ‘blue’. I want to then save this data into my config.php file as variables allowing my other website pages to access this data. Should this all be in an array as well?

<?php
//config file
$keyword = "computer";
$color = "blue";

?>

Also when I go back access the form again can I make it so the fields are prefilled with the data from the config.php file?

Any help would be much appreciated thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:52:17+00:00Added an answer on May 24, 2026 at 5:52 pm

    You can include your configuration file in your main php script file:

    // main.php
    <? php include("config.php"); ?>
    

    and build the form with something like this:

    // main.php
    <?php
    ?>
        <form method="post" name="config_form">
            <div id="field">
                <label>Keywords</label>
                <br />
                <input type="text" name="keyword">
            </div>
    
            <br />
    
            <select name="color">
                <option value="green" <? if ($color == "green") echo "SELECTED"; ?> >Green</option>
                <option value="orange" <? if ($color == "orange") echo "SELECTED"; ?> >Orange</option>
                <option value="blue" <? if ($color == "blue") echo "SELECTED"; ?> >Blue</option>
                <option value="red" <? if ($color == "red") echo "SELECTED"; ?> >Red</option>
            </select>
    
    </form>
    <?
    ?>
    

    finally you can save the form data in your config.php file using fopen() and fwrite() functions on form submit:

    $key = $_POST["key"];
    $color = $_POST["color"];
    
    if ($key != '' && $color != '') {
        $f = fopen('config.php', 'w') or die("can't open file");
        fwrite($f, '<?php $keyword=' . $key . ';$color=' . $color . ';?>');
        fclose($f);
    } else { // write default values or show an error message }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just looking for some direction when it comes to NHibernate and WCF. At
I was just looking through some information about Google's protocol buffers data interchange format.
Really quick here... I think I have the answer, but just looking for some
Does anyone have some numbers on this? I am just looking for a percentage,
just looking for some general direction/best practice about when to use a lookup value
Looking for some direction here as I'm running into some migration problems. We have
Admittedly, I am simply looking for some direction here. I have a specific situation,
I've done some Googling, and can't find anything, though maybe I'm just looking in
I'm looking at some vb.net code I just inherited, and cannot fathom why the
Just some days ago I started looking into a unit test framework called check,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.