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>

Recommended Answers

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.

Jump to Post

All 8 Replies

Re: How to store value permanently in an array using php 80 80

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.

Re: How to store value permanently in an array using php 80 80

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.

Re: How to store value permanently in an array using php 80 80
Member Avatar

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.

Re: How to store value permanently in an array using php 80 80

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

Re: How to store value permanently in an array using php 80 80

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.

Re: How to store value permanently in an array using php 80 80

Also a database offers better security of the data.

Re: How to store value permanently in an array using php 80 80
Member Avatar

You could always use a NoSQL database like Mongo: http://www.mongodb.org/

Re: How to store value permanently in an array using php 80 80

Thanks all of you guys for valuable ideas! :)

Be a part of the DaniWeb community

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