I have a form and need to submit it and save the data as a JSON file. Is it possible? If so how please?
Here is my simple form below.
<form action="#" method="">
<div data-role="fieldcontain">
<label for="date">Date Input:</label>
<input type="date" name="date" id="date" value="" /><br /><br />
<label for="textarea">Event:</label>
<textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>
<input type="submit" value="save to json" />
</div>
</form>
<?php
$file = dirname(__FILE__).'/form-data-'.time().'-'.rand(1000,9999);
file_put_contents($file, json_encode($_REQUEST));
?>
Read this post on google http://www.ryancoughlin.com/2009/05/04/how-to-use-jquery-to-serialize-ajax-forms/
I found it by googeling "jquery serialize form"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With