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

  • Home
  • SEARCH
  • 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 848425
In Process

The Archive Base Latest Questions

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

I have a an array I want, whenenever i submit my form the post

  • 0

I have a an array I want, whenenever i submit my form the post value get inserted into that array, every time with new incremented index..
How can I do that? And yes submited page is redirected to itself…

  • 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-15T06:56:25+00:00Added an answer on May 15, 2026 at 6:56 am

    You could solve this using the session-variables. This way the data won’t be overridden. Here’s an example:

    $_SESSION['formdata'][] = $_POST['value1'];
    $_SESSION['formdata'][] = $_POST['value2'];
    

    After you reload the script the data will still be available an pushing other values into the array won’t override the old ones. You just do it again:

    $_SESSION['formdata'][] = $_POST['value3'];
    $_SESSION['formdata'][] = $_POST['value4'];
    

    Calling the $_SESSION[‘formdata’]-Array you now have all 4 values stored in there.

    ** EDIT **
    I am finally home, and as promised I’m offering another solution using cookies, since sessions don’t work for you, as we’ve already discussed. So here we go…

    First of all we need to think of the way we want to name the cookie. I would suggest we would do this by ip-address and any suffix, to ensure, that it is really the user who has already filled, the former forms.

    So we could go like this:

    $dataArray[] = $_POST['value1'];
    $dataArray[] = $_POST['value2'];
    

    Then we need to store the data into an cookie. We do this by serializing the array, since we don’t want to save hundreds of cookies. This would work like this:

    $cookievalue = serialize($dataArray);
    
    // Here we actually generate a cookiename in the format of "IP_formdata"
    setcookie($_SERVER['REMOTE_ADDR'] . '_formdata', $cookievalue);
    

    So far so good. Within the next form we retrieve the cookie-data and unserialize the data, so we can extend this array:

    $dataArray = unserialize($_COOKIE[$_SERVER['REMOTE_ADDR'] . '_formdata');
    

    Now we can add other values to the array from the second form:

    $dataArray[] = $_POST['value3'];
    $dataArray[] = $_POST['value4'];
    

    After all additional values have been put into this array we serialize it again and store it into the again again:

    $cookievalue = serialize($dataArray);
    setcookie($_SERVER['REMOTE_ADDR'] . '_formdata', $cookievalue);
    

    Now we can repeat this steps for all further forms. Just remember that if you want to work with the data you first have to unserialize the data and store it into an array.

    And don’t forget as I have already stated in the comments: The user can turn off cookies, then the whole thing won’t work. You could also add some additional checks to verify that this is the correct user or something. I haven’t tested the code, but I think it should work in a way like this and I hope I could help you or at least give you a hint 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 408k
  • Answers 408k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I am also getting this issue with MAMP and passenger.… May 15, 2026 at 6:56 am
  • Editorial Team
    Editorial Team added an answer Depending on your application, you might want to consider a… May 15, 2026 at 6:56 am
  • Editorial Team
    Editorial Team added an answer You would have to escape the string so it works… May 15, 2026 at 6:56 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.