Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8591111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:27:04+00:00 2026-06-11T23:27:04+00:00

Files index.php <form name=postform action=post.php method=post enctype=multipart/form-data> <table class=postarea id=postarea> <tbody> <tr> <td class=postblock>Date:</td><td><input

  • 0

Files

index.php

<form name="postform" action="post.php" method="post" enctype="multipart/form-data">
<table class="postarea" id="postarea">
    <tbody>
<tr>    <td class="postblock">Date:</td><td><input type="text" name="startDate"></td></tr>
<tr>    <td class="postblock">Title:</td><td><input type="text" name="headline"></td></tr>
<tr>    <td class="postblock">Article:</td><td><textarea id="text" rows="5" cols="30" type="text" name="text"></textarea> </td> </tr>
<tr>    <td class="assetblock">Image address:</td><td><input type="text" name="media"></td></tr>
<tr>    <td class="assetblock">Image caption:</td><td><input type="text" name="caption"></td></tr>

<tr>    <td class="postblock"></td><td> <input type="submit" value="Submit Entry"> </td>    </tr>
</tbody>
</table>
</form>
</form>

post.php

<?php
// check if a form was submitted
if( !empty( $_POST ) ){
// convert form data to json format
$json = json_encode( $_POST );
// make sure there were no problems
//if( json_last_error() != JSON_ERROR_NONE ){
    //exit;  // do your error handling here instead of exiting
// }
$file = 'entries.json';
// write to file
//   note: _server_ path, NOT "web address (url)"!
file_put_contents( $file, $json, FILE_APPEND);
}   

Question

I am trying to create a form that will allow my users to add entries to the site. Entries are stored in a JSON file. I have created a form that submits to the JSON form and is formatted like this:

{"startDate":"example",
"headline":"example",
"text":"example",
"media":"example",
"caption":"example"}

Media and caption relate to an image, video or other multimedia, i need them to be stored as a separate object like the example below.

 {"startDate":"example",
 "headline":"example",
 "text":"example",
 "asset" :{"media":"example",
          "caption":"example"}
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:27:06+00:00Added an answer on June 11, 2026 at 11:27 pm
    <?php
    // check if a form was submitted
    if( !empty( $_POST ) ){
    
    // convert form data to json format
        $postArray = array(
          "startDate" => $_POST['startDate'],
          "headline" => $_POST['headline'],
          "text" => $_POST['text'],
          "asset" => array(
             "media" => $_POST["media"],
             "caption" => $_POST['caption']
            )
        ); //you might need to process any other post fields you have..
    
    $json = json_encode( $postArray );
    // make sure there were no problems
    //if( json_last_error() != JSON_ERROR_NONE ){
        //exit;  // do your error handling here instead of exiting
    // }
    $file = 'entries.json';
    // write to file
    //   note: _server_ path, NOT "web address (url)"!
    file_put_contents( $file, $json, FILE_APPEND);
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the form form action=index.php method=POST enctype=multipart/form-data > <input type=file name=image[] multiple=multiple> <input
I have a form to upload image like below <form name=sample enctype=multipart/form-data action=index.php method=post
I have this form: <form action=image_upload.php method=post enctype=multipart/form-data> Image 1: <input type=file name=event_image />
I have the follwing code <form enctype="multipart/form-data" action="upload.php" method="POST"> Please choose a file: <input
i am having an form for uploading an excel file like <form enctype=multipart/form-data action=http://localhost/joomla/Joomla_1.5.7/index.php?option=com_jumi&fileid=7
I have a form like below on my index page: <form action=send.php method=POST> <b>Your
I have a form for uploading image. The index.html submits data to resizer.php. The
I have 2 files : index.php, form.php. form.php: <?php if (isset($_POST['submit'])){ echo OK; //
I'm experiencing a very odd upload problem. Here's the relevant view file: <form action=http://localhost/index.php/temp/upload/
If I have three files index.php file.php and fns.php First example (it works): index.php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.