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的更多相关文章

  1. Oracle系列:记录Record

    Oracle系列:记录Record   分类: [Oracle] (15) 版权声明:本文为博主原创文章,未经博主允许不得转载. Oracle系列:记录(Record) 一,什么是记录(Record) ...

  2. 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 ...

  3. 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 ...

  4. pl/sql中record和%rowtype整理

    1. 创建stu表,如下: create table stu(s1 number, s2 number); 2. 定义多维数组, 能用来接受多条返回数据 方式一:   type type_name i ...

  5. 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 ...

  6. PHP安全编程

    转自:http://www.nowamagic.net/librarys/veda/detail/2076   1.关闭register_globals,以提高安全性 2.在部署环境,不要让不相关的人 ...

  7. Oracle学习笔记之存储过程

                                                                                                        ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 配置两个不同kerberos认证中心的集群间的互信

    两个Hadoop集群开启Kerberos验证后,集群间不能够相互访问,需要实现Kerberos之间的互信,使用Hadoop集群A的客户端访问Hadoop集群B的服务(实质上是使用Kerberos Re ...

  2. C#条码生成及打印实例代码

    ";//条码 ; ; //打印按钮 private void button1_Click(object sender, EventArgs e) { //实例化打印对象 PrintDocum ...

  3. 创建和使用CI / CD管道【译】【原】

    在GitLab 8.8中引入. 介绍 管道是持续集成,交付和部署的顶级组件. 管道包括: 定义要运行的作业的作业.例如,代码编译或测试运行. 定义何时以及如何运行的阶段.例如,该测试仅在代码编译后运行 ...

  4. 版本控制器:Git-的使用

    版本控制器:Git # 达到多人协同开发的目的 安装 """ 1.下载对应版本:https://git-scm.com/download 2.安装git:在选取安装路径的 ...

  5. 【真】CSP2019退役记(upd:12.21)

    这是第一次CSP(Counter-Strike Professor),也是最后一次. Day-1 上午考试,日常被虐. 下午颓mc Day0 上午考试,日常被虐. 下午颓mc 晚上看了下悬线法.最小表 ...

  6. Android Drawable和Bitmap区别

    一.相关概念 1.Drawable就是一个可画的对象,其可能是一张位图(BitmapDrawable),也可能是一个图形(ShapeDrawable),还有可能是一个图层(LayerDrawable) ...

  7. idea中导入Maven项目,但是没有Maven Dependencies,且没有pom

    1. 可以复制其他项目的类似的pom.xml文件复制到当前项目下 2. 导入此项目为maven项目 3. 配置相应的maven环境 4. 如果此时的Application.class中的main方法没 ...

  8. MongoDB Spark Connector 实战指南

    Why Spark with MongoDB? 高性能,官方号称 100x faster,因为可以全内存运行,性能提升肯定是很明显的 简单易用,支持 Java.Python.Scala.SQL 等多种 ...

  9. C#-Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046}

    异常信息如下 捕获到执行这句时异常: Excel.Application ep = new Excel.ApplicationClass(); Retrieving the COM class fac ...

  10. Kubernetes学习之路(27)之k8s 1.15.2 部署

    目录 一.环境准备 二.软件安装 三.部署master节点 四.部署node节点 五.集群状态检测 一.环境准备 IP地址 节点角色 CPU Memory Hostname Docker versio ...