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 ...
随机推荐
- 2019 小红书java面试笔试题 (含面试题解析)
本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.小红书等公司offer,岗位是Java后端开发,因为发展原因最终选择去了小红书,入职一年时间了,也成为了面试官 ...
- 2019-08-01 Ajax实现从数据库读取表
php代码 <?php //用pdo连接数据库 $dsn = 'mysql:host=127.0.0.1;port=3306;charset=utf8;dbname=news'; //实例化PD ...
- JavaScript 运算符(Operator)
一.算数运算符 1.加法(+) 表示操作数相加: 处理特殊值规则: 如果两个操作数都是字符串,则将第二个操作数与第一个操作数拼接起来: 如果只有一个操作数是字符串,则将另一个操作数转换为字符串,然后 ...
- android.view.ViewRoot$CalledFromWrongThreadException 异常的解决方案
https://blog.csdn.net/vincent_czz/article/details/7070354 https://stackoverflow.com/questions/210141 ...
- redis-5.0.5安装(linux centos)
下载 cd /data wget http://download.redis.io/releases/redis-5.0.5.tar.gz 历史版本库地址 http://download.redis. ...
- efcore 关联插入
出现这个错误: at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) Mi ...
- 解决使用Microsoft Graph OAuth获取令牌时,没有refresh_token的问题
今天在使用Microsoft Graph 的时候,发现按照官方文档,无论如何都不能获取refresh_token,其他都没问题,经过查询,发现是因为在第一步,获取code授权时,没有给离线权限(off ...
- Docker搭建Redis
1.拉取redis镜像: docker pull redis 2.创建容器: docker run -d --restart=always -v /opt/redis/data:/data --nam ...
- 微信开发:"errcode": -1000,"errmsg": "system error"错误的解决办法
最近在微信开发使用微信公众平台接口调试工具时遇到错误. 错误再现:使用appid及appsecret在该测试工具中获取access_token,检查问题时,校验全部通过,但是无法获取access_to ...
- com.alibaba.fastjson.JSONException: exepct '[', but error, pos 1, json : %255B%257B%2522list%2522%253A%255B%257B%2522itemId%2522%253A1369331%252C%2522num%2522%253A2%257D%255D%257D%255
com.alibaba.fastjson.JSONException: exepct '[', but error, pos 1, json : %255B%257B%2522list%2522%25 ...