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 7641333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:53:45+00:00 2026-05-31T08:53:45+00:00

I have a project with a paranoid client… He is worried the site is

  • 0

I have a project with a paranoid client… He is worried the site is going to crash if more than 200 people are using the site at the same time.

Does my script look like it will collect the data okay? Or will the file give users errors?

<?php
if($_POST['name'] && $_POST['email']) {
    //file name var
    $fileName = "mycsvfile.csv";

    //grab from form
    $name = $_POST['name'];
    $email = $_POST['email'];

    //date
    date_default_timezone_set("America/Los_Angeles");
    $today = date("F j, Y, g:i a");

    //set the data we need into an array
    $list = array (
        array($today, $name, $email)
    );

    // waiting until file will be locked for writing (1000 milliseconds as timeout)
    if ($fp = fopen($fileName, 'a')) {
      $startTime = microtime();
      do {
        $canWrite = flock($fp, LOCK_EX);
        // If lock not obtained sleep for 0 - 100 milliseconds, to avoid collision and CPU load
        if(!$canWrite) usleep(round(rand(0, 100)*1000));
      } while ((!$canWrite)and((microtime()-$startTime) < 1000));

      //file was locked so now we can store information
      if ($canWrite) {
        foreach ($list as $fields) {
            fputcsv($fp, $fields);
        }
      }
      fclose($fp);
    }

    //Send them somewhere...
    header( 'Location: http://alandfarfaraway' ) ;

}else{
    echo "There was an error with your name and email address.";
}
?>
  • 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-31T08:53:46+00:00Added an answer on May 31, 2026 at 8:53 am

    Use a database such as MySQL to store your data. It will handle a much higher load.

    http://php.net/manual/en/book.mysql.php

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

Sidebar

Related Questions

I have project asp.net with namespace test and I'm using resources (files Resource.resx and
I have project on rails 3 with multiplayer using Faye. The error block in
I am using Spring and Maven project. I have Project mit-webservices and mit-util project
I am very desperate now... I have project in Visual C++ 2010 using Qt
I have project that I'm working on that is going to require a webserver.
I have project where i'm developing an Android App using a lot of existing
We have project (PHP application), but instalation for each client vary, sometimes very little,
I have project I want to upgrade to .Net4 and it use BackgroundCopyManager.dll. Anyone
I have project Emle in Launchpad . I set it to import from emle.svn.sourceforge.net
I have project in Dropbox and two running laptops: one with Ubuntu and one

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.