prepare($sql); $stmt->bindParam(':username', $_POST['username']); $stmt->bindParam(':password', $password_hash); $stmt->bindParam(':email', $_POST['email']); // execute the statement $stmt->execute();
$_POST['username'], 'password' => password_hash($_POST['password'], PASSWORD_DEFAULT), 'email' => $_POST['email'] ); // encode the user data as JSON $json_data = json_encode($user_data); // save the JSON data to a file file_put_contents('users.json', $json_data);In this example, we define the user data as an associative array and encode it as JSON using the json_encode function. We then use the file_put_contents function to save the JSON data to a file called "users.json". This method can be useful for small-scale applications, but is not recommended for large-scale applications due to potential security vulnerabilities. Package Library: The package library used in this example is PHP PDO for database storage and the in-built file functions in PHP for file storage.