I want to store these submitted values. Can it be possible without database? using just array. I don't want to store values for a session. Just for long time unless deleted.

<form id="form1" name="form1" method="post" action="">
<form id="form1" name="form1" method="post" action="">

  <p>
    <label for="num1">Some text</label>
    <input type="text" name="num1" id="num1" />
  </p>
  <p>
    <label for="num2">some text</label>
    <input type="text" name="num2" id="num2" />
  </p>
  <p>
    <input type="radio" name="r" id="add" value="add" />
    <label for="add">Addition</label>
  </p>
  <p>
    <input type="radio" name="r" id="sub" value="sub" />
    <label for="sub">Subtraction</label>
  </p>
  <p>
    <input type="radio" name="r" id="mul" value="mul" />
    <label for="mul">Multiplication</label>
  </p>
  <p>
    <input type="radio" name="r" id="div" value="div" />
    <label for="div">Division</label>
  </p>

  <p>
    <label for="select">select</label>
    <select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>
  </p>
</form>

You can save values in a txt file, JSON format would be a good one. You can use json_encode and json_decode functions. Instead of JSON you can just serialize data into a txt file.

Other than storing your data in plain text file as broj1 has pointed out, you could also store it in a XML file. You can use cookie, but please DO NOT use this approach if you are storing sensitive information. Also remeber that there is a limitation on how much data you can store in a cookie. I think the limit is around 4096 bytes.

Member Avatar for diafol

This type of approach rarely ends well. :(
Well, that's not strictly true, but a DB would be better for storage.

If you have a number of users, each storing a file - it could get very messy.

Yeah, that is true. He should use a database.

Yes broj1 is right,use text file if data is not that hugeand is constant(very rarely updated).But if data is huge and is changing consistenly then it will be better to use datbase only.

Also a database offers better security of the data.

Thanks all of you guys for valuable ideas! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.