Reputation: 49422
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>
Upvotes: 3
Views: 8262
Reputation: 3928
<?php
$file = dirname(__FILE__).'/form-data-'.time().'-'.rand(1000,9999);
file_put_contents($file, json_encode($_REQUEST));
?>
Upvotes: 7
Reputation: 9382
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"
Upvotes: 2