手记账极速版 (html + php) 告别后端和数据库 附完整代码

导读:本篇文章讲解 手记账极速版 (html + php) 告别后端和数据库 附完整代码,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

 手账极速版旨在于让不想自己搭建后端和数据库的兄弟们有一个快捷的 html+php 并且能永久保存数据的小工具 底部有一个试用链接

手记账极速版 (html + php) 告别后端和数据库 附完整代码

 

虽然看起来很简单,但是真的要实现不用数据库只用前端还是花了一点时间的,并且有JS一些功能只有微软的浏览器可以使用,但是最终还是实现了

具体实现:

废话不多说,都有注释,直接上代码,复制过去,不需要任何部署,直接开始使用

一共是两个文件:

index.php

<!DOCTYPE html>
<html lang="en">
<base target="_blank">
<head>
    <title>长歌手账极速版</title>
</head>

<body class="theme-invert">
<!-- Main (Home) section -->
<section class="section" id="head">
    <?php
		//长歌手账极速版 下面这一段都是用来创建和读取dat里面的数据的
		$CounterFile = "counter.dat";
		if(!file_exists($CounterFile)){		//初始化
			$counter = 0;					
			$cf = fopen($CounterFile,"w");	//打开文件
			fputs($cf,'0');					//初始化计数器
			fclose($cf);					//关闭文件
		}
		else{										//取回当前计数器的值
			$cf = fopen($CounterFile,"r");
			$counter = trim(fgets($cf,9));
			fclose($cf);
		}
		$cf = fopen($CounterFile,"w");				//写入新的数据
		fputs($cf,$counter);
		fclose($cf);
	    $String="\r\n";
					//计数器加一
	?>
    //花钱提示
    <div id="dd" align="center">
        <span>您已经花了</span>
        <span>
			<?php
			 echo $counter;		
			?>
            这么多钱啦!</span>
    </div>
    //交钱提示按钮
    <iframe name="formSubmit" style="display:none;"></iframe>
    <form class="form-inline" target="formSubmit" method="post">
        <input id="input" type="text" placeholder="交钱了!" name="chishi"></input>
        <input onclick="mymethon(<?php
			 echo $counter;						
			?>)" name="button1" type="submit" id="input1"></input>
    </form>

//这一段其实没什么用,但是舍不得删除
    <script type="text/javascript">
        var a = <?php
        echo
        $counter;
            ?
        >
        ;

        function mymethon(hah) {
            a = parseInt(a) + parseInt(document.getElementById("input").value);
            alert(a);
        }

    </script>
</body>
//写入你花的钱
<?php
    if (array_key_exists('button1',$_POST)){
		//长歌手账极速版
        $datt = $_POST["chishi"];
    		$CounterFile = "counter.dat";	
    		$cf = fopen($CounterFile,"w");	
    		fputs($cf,(String)((float)$counter+(float)$datt));
    		fclose($cf);
    }
	?>
</html>

和counter.dat

直接同个目录下创建文件然后输入0就好了,非常的方便

手记账极速版 (html + php) 告别后端和数据库 附完整代码

所有文件: 

 手记账极速版 (html + php) 告别后端和数据库 附完整代码

 试用链接:

这只是最基础的功能,也是最核心的,已经实现了,剩下的改造也是会简单很多

↓点击跳转

长歌手账极速版 试用链接

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/73520.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!