我是编程的新手 [英] Iam a newbie to programming

查看:94
本文介绍了我是编程的新手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php  
 $message = '';  
 $error = '';  
 if(isset($_POST["submit"]))  
 {  
      if(empty($_POST["name"]))  
      {  
           $error = "Enter name";  
      }  
      else if(empty($_POST["datedon"]))  
      {  
           $error = "Enter Date";  
      }
      else if(empty($_POST["timeon"]))  
      {  
           $error = "Enter Time";  
      }  
      else  
      {  
           if(file_exists('try.json'))  
           {  
                $current_data = file_get_contents('try.json');  
                $array_data = json_decode($current_data, true);  
                $extra = array(  
                     'name'               =>     $_POST['name'],
                     'datedon'     =>     $_POST["datedon"],
                     'timeon'     =>     $_POST["timeon"],  
                );
                $array_data[] = $extra;
                $final_data = json_encode($array_data);
                if(file_put_contents('try.json', $final_data))
                {  
                     $message = "Deals Added Successfully<p></p>";  
                }  
           }  
           else  
           {  
                $error = 'JSON File not exits';  
           }  
      }  
 }  
 ?>





我是什么尝试过:



当我得到名字等输入时。应该在顶部添加而不是在json文件的底部



What I have tried:

when ever i get input like name etc. It Should be added at the top not at the botton of json file

推荐答案

message ='';
message = '';


error ='';
if(isset(
error = ''; if(isset(


_POST [submit]))
{
if(empty(
_POST["submit"])) { if(empty(


这篇关于我是编程的新手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆