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 ...
随机推荐
- js 加密方法Encrypt
function Encrypt(str, pwd) { if (str == "") return ""; str = escape(str); if (!p ...
- Space Syntax(空间句法)
01 December 2019 13:16 https://spacesyntax.com/ 相关软件:Depthmap 空间句法理论作为一种新的描述建筑和城市空间模式的语言 ...
- w3c网站案例
w3c网站 reset操作 body { background-color: #eee; } html, body, h1, h2, h3, h4, h5, h6, ul, p { margin: 0 ...
- 全程实操cdh5.14.4中集成安装kylin2.4.1与使用测试
在cdh5.14.4安装完成并排错完成的情况下,进行如下kylin安装操作: 1.实验环境 三台CentOS 7主机,IP地址 192.168.43.129 cm1 192.168.43.130 cm ...
- vue学习整理
1.webpack+vue自定义路径别名 vue-cli 用的是webpack,也可以使用webpack自定义别名这个功能,自定义别名这个功能当你在多层文件夹嵌套的时候不必一层一层找路径,直接使用自定 ...
- js对数组array的常见操作小结
1.创建数组?两种方式 var arr = new Array("1","2","4"); var arr1 = ["1" ...
- Android-----解析xml文件的三种方式
SAX解析方法介绍: SAX(Simple API for XML)是一个解析速度快并且占用内存少的XML解析器,非常适合用于Android等移动设备.SAX解析XML文件采用的是事件驱动,也就是说, ...
- Integrated SOA Gateway 不是当前用户的有效责任。请联系您的系统管理员。
问题:给用户新增职责集成SOA网关,点击路径进入时出现报错:"Integrated SOA Gateway 不是当前用户的有效责任.请联系您的系统管理员." 解决:功能管理员职责, ...
- 一招解决------VMware虚拟机 Centos7网络配置 ping:www.baidu.com:未知的名称或服务 ping不通
一招解决------VMware虚拟机 Centos7网络配置 ping:www.baidu.com:未知的名称或服务 ping不通 1.首先点击VMware的编辑,再点击虚拟网路编辑器. 2.进入虚 ...
- Kubernetes学习之路(27)之k8s 1.15.2 部署
目录 一.环境准备 二.软件安装 三.部署master节点 四.部署node节点 五.集群状态检测 一.环境准备 IP地址 节点角色 CPU Memory Hostname Docker versio ...