Input data from email form not going to JSON file


I have added an email input / form to my WordPress page and want to collect the information from this as JSON data.

The HTML code is:

<form method="get"><p id="myform"><input type="email" name="EMAIL" placeholder="enter email address" required />
<input id="submit" type="submit" value="Sign up" /></p></form>

The php, which is in my functions.php file, is:

if (isset($_POST['submit'])) {
$file = "data.json";
$json_string = json_encode($_POST, JSON_PRETTY_PRINT);
file_put_contents($file, $json_string, FILE_APPEND);

I have a data.json file, which is being referenced in the php part of the above code, which sits at the first level of my child theme.

I’m not getting any error messages, and the input field is allowing email addresses to be input, but the data isn’t going to my data.JSON file.

I can’t seem to work out why?

Any help would be fab.



>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="">

Input data from email form not going to JSON file</a>
, , , The Chewy 4 years 0 Answers 52 views 0

Leave an answer