mercredi 31 août 2016

How do I record JSON data to file using PHP?

This is the code I've figured out.

<?php
$username = $_POST['username'];
$email = $_POST['email'];
$json = '{"username":"'.$username.'",'.'"email":"'.$email.'"}';
$file = fopen('token_data.json','w+');
fwrite($file, $json);
fclose($file);
?>

But this is absolutely not the right way.

Aucun commentaire:

Enregistrer un commentaire