How to save data with PHP without using a database

During this time, data and information must be stored in the database. In reality, however, data and information can be stored in files with the extension html, txt, php, etc. You don’t have to wait long, please refer to the following code:

Let’s get down to a few examples in a moment.

1. Open the XAMPP control panel and activate Apache and MySql.

2. Open a text editor such as Notepad ++ or Dreamweaver and enter the following HTML script code.

Save the script code above, save it in the xampplite folder – htdocs – create a new folder (here I create a new folder called “inwepo”) – I save it with the filename “save-data.php”.

Simpan Data

Simpan Data Tanpa Database

Nama
Isi

3. To see the results of the script code above, you can open your browser and type in http: //localhost/inwepo/save-data.php.

4. Add the following PHP code to process it and save it to a file.

 ");        fwrite($buka,"dibuat : ${tanggal} 
"); fwrite($buka," isi : ${data}
"); fwrite($buka,"

5. Reload http: //localhost/inwepo/save-data.php again.

Try to see the results by opening the results.html file.

6. The result.html file is saved in the folder in which the ‘save-data.php’ file is located. Since my ‘save-data.php’ file is in the htdocs folder, the result.html file is in the htdocs folder.

7. Results display.html

Remarks:

1. Maybe someone is still confused why it should be stored in htdocs? Htdocs is one of the standard folders of XAMPP, whose special task is to store files to be executed such as PHP, HTML, CSS and JavaScript files.

2. Then maybe someone asks about the meaning of http: //localhost/inwepo/save-data.php. Localhost is a local server on the computer. Localhost can be activated by clicking Start Apache in the XAMPP control panel. Inwepo refers to my inwepo folder in xampplite – htdocs. And save-data.php is the name of the file that is saved in the script code above.

Hence the explanation of the tutorial on ‘How to store data with PHP without using a database’. Much luck.






Leave a Reply

Your email address will not be published.