PHP Record the number of login users
Function to record how many times the user logs in
Connect to the database first:
you can create a new php file :
The following code:
php file name is conn.php
<?php
header("Content-type:text/html;charset=utf-8");
$conn = mysql_connect('localhost','root','') or die('Server connection failed');
mysql_select_db('database name') or die('database nonexistence');;
mysql_query('set names utf-8');
?>
you can create a new php file :
The following code:
php file name is login.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>login</title>
</head>
<body>
<form action="logindo.php" method="post">
users: <input name="name" type="text"/><br/>
cipher:<input name="password" type="password"/></br>
<input type="submit" name="sub" value="submit"/>
</form>
</body>
</html>
you can create a new php file :
The following code:
file named :logindo.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>login handling</title>
</head>
<body>
<?php
if(isset($_POST['sub'])){
include('conn.php');
$name = $_POST['name'];
$password = $_POST['password'];
$sql = "select * from tb_name where name = '$name' and password = '$password'";
$r = mysql_query($sql);
if($row = mysql_fetch_array($r)){
session_start();
$_SESSION['name']=$row['name'];
$ac = 0;
if(file_exists("acc.txt")){
$ac = file_get_contents("acc.txt");
}
$ac++;
file_put_contents("acc.txt",$ac);
echo '<script>alert('login success');location.href="index.php";</script>';
}else{
echo '<script>alert("user name or password error");location.href="login.php";</script>';
}
}else{
echo '<script>alert("user name or password error");location.href="login.php";</script>';
}else{
echo '<script>alert("user name or password error");location.href="login.php";</script>';
}
?>
</body>
</html>
you can create a new php file :
The following code:
index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>User registration login procedure</title>
</head>
<body>
<?php
session_start();
if(isset($_SESSION['name'])){
echo 'welcome'.$_SESSION['name'];
echo "<br>";
$ac = file_get_contents("acc.txt");
echo "you are".$ac."visitor";
}else{
echo "<script>alert('please login');location='loginl.php';</script>";
}
?>
<a href="exit.php">Logged out</a>
</body>
</html>
you can create a new php file :
The following code:
file name is exit.php
<?php
header("Content-type:text/html;charset=utf-8");
session_start();
unset($_SEEION['name']);
echo '<script>alert("exit the success");location="login.php";</script>';
?>
The datadase is as follows:
create database (database);
use (database);
create table (table_name);
create table 'table_name' ( 'id' int(4) not null auto_increment primary key,'name' varchar(50) character set utf8 collate utf8_unicode_ci not null,'password' varchar(50) character set utf8 collate utf8_unicode_ci not null,'createtime' datetime not null ) engine = myisan character set utf8 collate utf8_unicode_ci;
welcome to view
PHP Record the number of login users的更多相关文章
- Oracle系列:记录Record
Oracle系列:记录Record 分类: [Oracle] (15) 版权声明:本文为博主原创文章,未经博主允许不得转载. Oracle系列:记录(Record) 一,什么是记录(Record) ...
- Method for Estimating the Number of Concurrent Users
1. Formula for Estimating the Average Number of Concurrent users We begin by defining what the numbe ...
- Method and apparatus for encoding data to be self-describing by storing tag records describing said data terminated by a self-referential record
A computer-implemented method and apparatus in a computer system of processing data generated by a f ...
- pl/sql中record和%rowtype整理
1. 创建stu表,如下: create table stu(s1 number, s2 number); 2. 定义多维数组, 能用来接受多条返回数据 方式一: type type_name i ...
- Total Commander 8.52 Beta 1
Total Commander 8.52 Beta 1http://www.ghisler.com/852_b1.php 10.08.15 Release Total Commander 8.52 b ...
- PHP安全编程
转自:http://www.nowamagic.net/librarys/veda/detail/2076 1.关闭register_globals,以提高安全性 2.在部署环境,不要让不相关的人 ...
- Oracle学习笔记之存储过程
...
- Hue 之 SparkSql interpreters的配置及使用
1.环境说明: HDP 2.4 V3 sandbox hue 4.0.0 2.hue 4.0.0 编译及安装 地址:https://github.com/cloudera/hue/releases/t ...
- mysql的TABLE_SCHEMA的sql和information_schema表, MySQL管理一些基础SQL语句, Changes in MySQL 5.7.2
3.查看库表的最后mysql修改时间, 如果第一次新建的表可能还没有update_time,所以这里用了ifnull,当update_time为null时用create_time替代 select T ...
随机推荐
- Echarts 学习系列(1)-5分钟上手ECharts
目录 写在前面 下载Echarts和主题 绘制一个简单的图表 写在前面 最近,在做某个项目的时候.需要使用的可视化的图表显数据.最后,选择了百度的Echarts. 下载Echarts和主题 1.获取E ...
- .NET Core MD5加密 32位和16位
public class MD5Help { //此代码示例通过创建哈希字符串适用于任何 MD5 哈希函数 (在任何平台) 上创建 32 个字符的十六进制格式哈希字符串官网案例改编 /// <s ...
- APS.NET MVC + EF (04)---路由和数据传递
4.1 视图引擎 ASP.NET MVC 提供两种视图引擎:ASPX(C#)和Razor(CSHTML),推荐使用Razor. 4.1.1 Razor的语法 在Razor视图中,所有的服务器端代码都是 ...
- java log4j 打日志到控制台同时打印到不同文件
1.pom配置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="htt ...
- spring整合MyBatis思路
目录 整合目标 需要的jar 整合思路 加入配置文件 整合目标 控制层采用springMVC.持久层使用mybatis实现. 需要的jar spring(包括springmvc) mybatis my ...
- Netty入门系列(1) --使用Netty搭建服务端和客户端
引言 前面我们介绍了网络一些基本的概念,虽然说这些很难吧,但是至少要做到理解吧.有了之前的基础,我们来正式揭开Netty这神秘的面纱就会简单很多. 服务端 public class PrintServ ...
- MFC中窗口重绘
搬家于CSDN 2015-05-14 MFC提供了三个函数用于窗口重绘 InvalidateRect(&Rect) Invalidate() UpdateWindow() 当需要更新或者重绘窗 ...
- vue使用html2canvas生成图片并保存到本地
html2canvas官方文档 http://html2canvas.hertzen.com/ npm下载依赖 npm install html2canvas -S 在需要使用的地方引入 import ...
- uni-app学习
1. 学习uni-app 1.1. 概述 号称一次编写多端运行的前端框架,架构图如下 对某些不同平台的特殊功能,可以通过条件进行自动编译,也就是写两套代码,不同的环境会选择不同代码编译 1.2. 推荐 ...
- Android-----File(文件各种操作)
在Android编程中,操作文件是基本的必备技能,现在做一个操作文件的小工具:DocumentTool.java 代码如下: package com.hs.example.exampleapplica ...