how to store data with php
snippet in php

how to store data with php

user9695

<?php
    //Get a secure filename so no one can get your server files
    $username = "myUsername"
    $filename = uniqid($username, true).".csv";
	//You can change the .csv file to a .txt

    //Create the array that stores data. You can replace what is below with what you want
    $userInfo = ["username" => $username, "points" => 0];

    // Store the data
    file_put_contents($filename, serialize($userInfo));

    // How to get the data
    $userInfo = unserialize(file_get_contents($filename));
    print($userInfo["points"]);
    // or
    print($userInfo["username"]);
	//Make sure that ^^^^ matches what is in the array
?>