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. C# SQl通过对视图数据二次查询,统计数据

    问题描述: 原数据---------需要在原视图数据中,统计出每个Device_Num设备号下面的交易的总额和分别统计出微信支付宝的交易总额. 解决:从上图数据没办法使用直接查询出要求的数据. .1. ...

  2. 2019 头条java面试笔试总结 (含面试题解析)

       本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条等公司offer,岗位是Java后端开发,因为发展原因最终选择去了头条,入职一年时间了,也成为了面试官,之前面 ...

  3. 深圳宝安图书馆官网错误 HTTP Status 500 - Servlet.init() for servlet spring threw exception

    停留了一段时间没有动 打开https://www.balib.cn/balib/category/152 *********************************************** ...

  4. mui之href页面跳转

    <a class="mui-control-item" href="" onclick="window.location.href = 'dai ...

  5. 医疗行业预测性产品的质量如何把关?MES系统帮大忙

    作为行业细分的医疗设备制造正在向工业4.0快速发展.它也可能仍然是世界上受监管最严格的行业之一,产品的个性化发展速度比其他行业更快. 在医疗设备行业中,由于需求或由于市场特定的规定,产品越来越多地定制 ...

  6. JS案例 - 城市三级联动

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. 连接mysql报"ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server"

    最近在服务器上部署好的应用突然间连接不上mysql数据库,报错“ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this M ...

  8. 【Spring Cloud】Spring Cloud之Zipkin server搭建以及HTTP收集,分布式服务跟踪(2)

    一.搭建步骤 1)新建Spring Boot项目,引入pom坐标 <parent> <groupId>org.springframework.boot</groupId& ...

  9. Odoo日历视图详解

    转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826148.html 一:日历视图定义 根元素为<calendar>. 主要的属性有:    ...

  10. Fedora 安装 MongoDB 教程

    MongoDB 安装 本文原始地址:https://sitoi.cn/posts/37161.html 安装环境 Fedora 29 安装步骤 安装 mongodb 和 mongodb-server ...