Php简介:
引用:PHP即“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法学习了C语言,吸纳Java和Perl多个语言的特色发展出自己的特色语法,并根据它们的长项持续改进提升自己,例如java的面向对象编程,该语言当初创建的主要目标是让开发人员快速编写出优质的web网站。 PHP同时支持面向对象和面向过程的开发,使用上非常灵活。
经过二十多年的发展,随着php-cli相关组件的快速发展和完善,PHP已经可以应用在 TCP/UDP服务、高性能Web、WebSocket服务、物联网、实时通讯、游戏、微服务等非 Web 领域的系统研发。
我们开发php网站需要配置apache、mysql,利用集成环境开发网站,例如小皮面板、xampp等集成环境,现在我们利用PHP来做一个登录功能
前端页面:login.php
d877c38dfe6d3005ccc9b7336fbcdac0
8b05045a5be5764f313ed5b9168a17e6
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
ff94e7be1619a095952b0217c283b66c
9325f07d5ee000b791aa0e2d41c3ea79
b3c7cea9c5108026d29b214f796ba7df
e2704e862f167f39bfd113ae9c01df49
0069d8560d7bc062194b41882d743b38
e7bc5a6abff9afa5c73f1d398bb71886
8448925f133ecdbd4e628430b59244a12cacc6d41bbb37262a98f745aa00fbf0
5994da34af0234834cd8d632d4f1c5262cacc6d41bbb37262a98f745aa00fbf0
965237357465df1d11fca0161b31af3f2cacc6d41bbb37262a98f745aa00fbf0
ccb8621b7aad48c9d8a562dc099b48cc2cacc6d41bbb37262a98f745aa00fbf0
b2386ffb911b14667cb8f0f91ea547a76e916e0f7d1e588d4f442bf645aedb2f
9c3bca370b5104690d9ef395f2c5f8d1
6c04bd5ca3fcae76e30b72ad730ca86d
835db59e8bcc1934cc580fe4102b1403
173a25ad879eae6adfb1e8cf88265940
dc6dce4a544fdca2df29d5ac0ea9906b
560dc2cf5f61286c5337771d4be6cf3d
0c998a498d4bb99d357fbd026a89bea0
f86d17131095e9d8f5b66739f80fa4f954bdf357c58b8a65c66d7c19c8e4d114
65281c5ac262bf6d81768915a4a77ac0
16b28748ea4df4d9c2150843fecfba68
039dbc5dc7a2325bb985fa6d9a561642
45a2772a6b6107b401db3c9b82c049c2635837c3a36f47a8ad5df0921d7ac8a65a8028ccc7a7e27417bff9f05adf593272ac96585ae54b6ae11f849d2649d9e65db79b134e9f6b82c0b36e0489ee08ed54bdf357c58b8a65c66d7c19c8e4d114
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
0cb0d37bd827c253db804f192a046bde
926fbaeee457d63b300fd1ae81904598
030817b66d2175f2b3207b41152c7b9754bdf357c58b8a65c66d7c19c8e4d114
16b28748ea4df4d9c2150843fecfba68
6c12054be87346aec0920c394ee2e3aa
e002d7a8d07ee67e7173be47d1e5fd32
25edfb22a4f469ecb59f1190150159c6
9ef0119d98efbe01d0409e79cfac3925首页5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
7e3c38720c206efa7138f9ce6bc7e5ff模板5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
77bf89852c337d1d7b4d47d8b53d20a4套餐5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
778384ca7e0ca1540f93da8af939dd75案例5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
efc86c66f7c725828c13919863498098
3499910bf9dac5ae3c52d5ede7383485文档6f175935596a1cd4af1531ed20d13b9972ac96585ae54b6ae11f849d2649d9e65db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
a2133a93de9d57604e8dc99f6cc300a9
3499910bf9dac5ae3c52d5ede7383485关于6f175935596a1cd4af1531ed20d13b9972ac96585ae54b6ae11f849d2649d9e65db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
5ff5cd4398dedd2994f6accfe1c8d923
ff6d136ddc5fdfeffaf53ff6ee95f185
c03d504d8fc37b9626bd93af98b1a2d7
3499910bf9dac5ae3c52d5ede7383485返回上一级5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485教程中心5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485建站资讯5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485更新日志5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
16b28748ea4df4d9c2150843fecfba68
652d4590fa9c3531a196feced0178b72
db837f111b490cf2a843ae6be9f2a7fe
896cec2cf8296f982099bf97dda1e743
3499910bf9dac5ae3c52d5ede7383485返回上一级5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
5c62385e7862a64aa12abcb3e9fa6177
3499910bf9dac5ae3c52d5ede7383485公司信息6f175935596a1cd4af1531ed20d13b9972ac96585ae54b6ae11f849d2649d9e65db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485荣誉资质5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485联系客服5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
16b28748ea4df4d9c2150843fecfba68
1d9fdce3b806493b433d7504d01df5dd
ff6d136ddc5fdfeffaf53ff6ee95f185
205fb9efb3a8556c061ab3acdc87a0af
3499910bf9dac5ae3c52d5ede7383485返回上一级5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485公司介绍5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485服务条款5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485法律声明5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485可接受服务5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6
3499910bf9dac5ae3c52d5ede7383485免责声明5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
44f9630a3d507ae7532760da37622b0f
dc6dce4a544fdca2df29d5ac0ea9906b
dc6dce4a544fdca2df29d5ac0ea9906b
dc6dce4a544fdca2df29d5ac0ea9906b
c5f8d752a5a5b859c842b2f660c2c101
dc6dce4a544fdca2df29d5ac0ea9906b
7f7a76da34f48ad77c55494c9ffc859c用户名或邮箱8c1ecd4bb896b2264e0711597d40766c
53a41be44a280f7cf4025d65b6af70e0
16b28748ea4df4d9c2150843fecfba68
dc6dce4a544fdca2df29d5ac0ea9906b
39ced541509fd40cc54352ddf151ac55密码8c1ecd4bb896b2264e0711597d40766c
2845496f39d6af3c5f24f12ec05b80ce
16b28748ea4df4d9c2150843fecfba68
dc6dce4a544fdca2df29d5ac0ea9906b
2e1cf0710519d5598b1f0f14c36ba674
514d05be645eb7d51e331036aaf6fa36 记住我(请在私人计算机上使用此功能)
8c1ecd4bb896b2264e0711597d40766c
16b28748ea4df4d9c2150843fecfba68
dc6dce4a544fdca2df29d5ac0ea9906b
88aebddf53de96f3cea6473d134d71b2登录65281c5ac262bf6d81768915a4a77ac0
44238adb8e19c287e0d3e8312c798054注册5db79b134e9f6b82c0b36e0489ee08ed
16b28748ea4df4d9c2150843fecfba68
4a215f3237c3b605e995784b79619aa2
45a2772a6b6107b401db3c9b82c049c2其他账号登录:54bdf357c58b8a65c66d7c19c8e4d114
dc6dce4a544fdca2df29d5ac0ea9906b
c1a5f0a81dfd3a61af9b5bb2898516ed45a2772a6b6107b401db3c9b82c049c254bdf357c58b8a65c66d7c19c8e4d1145db79b134e9f6b82c0b36e0489ee08ed
fae4424bc87195d0e16684c11e10adfd45a2772a6b6107b401db3c9b82c049c254bdf357c58b8a65c66d7c19c8e4d1145db79b134e9f6b82c0b36e0489ee08ed
b628f8981bdfb2204efa6ce5df72691545a2772a6b6107b401db3c9b82c049c254bdf357c58b8a65c66d7c19c8e4d1145db79b134e9f6b82c0b36e0489ee08ed
1f8d53aa73690073d3cedf445a9880de45a2772a6b6107b401db3c9b82c049c254bdf357c58b8a65c66d7c19c8e4d1145db79b134e9f6b82c0b36e0489ee08ed
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
649884c9f235e0dc5bfe3cd9b4f6c158
8fb0647cc270c6c60ce1679670afa6fc忘记密码?点这里找回5db79b134e9f6b82c0b36e0489ee08ed
16b28748ea4df4d9c2150843fecfba68
f5a47148e367a6035fd7a2faa965022e
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
ff6d136ddc5fdfeffaf53ff6ee95f185
25edfb22a4f469ecb59f1190150159c6
9dba6f1f949f5e07bed667bf670fd9c4
484ccb1d2c4346f112100c2685cae6995a8028ccc7a7e27417bff9f05adf593272ac96585ae54b6ae11f849d2649d9e645a2772a6b6107b401db3c9b82c049c2在线客服54bdf357c58b8a65c66d7c19c8e4d11416b28748ea4df4d9c2150843fecfba68
5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
5a8028ccc7a7e27417bff9f05adf593272ac96585ae54b6ae11f849d2649d9e6
25edfb22a4f469ecb59f1190150159c6
9dba6f1f949f5e07bed667bf670fd9c4
0a7e317b1dfce37cc8b23791d662d5dd5a8028ccc7a7e27417bff9f05adf593272ac96585ae54b6ae11f849d2649d9e645a2772a6b6107b401db3c9b82c049c21766398512654bdf357c58b8a65c66d7c19c8e4d11416b28748ea4df4d9c2150843fecfba68
5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
5a8028ccc7a7e27417bff9f05adf593272ac96585ae54b6ae11f849d2649d9e6
25edfb22a4f469ecb59f1190150159c6
9dba6f1f949f5e07bed667bf670fd9c4
dc6dce4a544fdca2df29d5ac0ea9906b5a8028ccc7a7e27417bff9f05adf593272ac96585ae54b6ae11f849d2649d9e645a2772a6b6107b401db3c9b82c049c2免责声明54bdf357c58b8a65c66d7c19c8e4d11416b28748ea4df4d9c2150843fecfba68
5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
5a8028ccc7a7e27417bff9f05adf593272ac96585ae54b6ae11f849d2649d9e6
25edfb22a4f469ecb59f1190150159c6
9dba6f1f949f5e07bed667bf670fd9c4
86195a7140dcfa1b76cbb04b9b0239eb076402276aae5dbec7f672f8f4e5cc81 关注微信 " data-html="true">5a8028ccc7a7e27417bff9f05adf593272ac96585ae54b6ae11f849d2649d9e616b28748ea4df4d9c2150843fecfba68
5db79b134e9f6b82c0b36e0489ee08ed
bed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
16b28748ea4df4d9c2150843fecfba68
36cc49f0c466276486e50c850b7e4956
73a6ac4ed44ffec12cee46588e518a5e
后端代码:public/login.php
f28c08dd161c5d9f14f465f242ef19fcquery($sql);
if($result->num_rows>0){
$row=$result->fetch_assoc();//从结果集中取出一数组
echo json_encode($row);//转成json格式
session_start();
$_SESSION['name']=$user;
echo "cbcabc09e924becb49144e0c3123329d
window.location.href='../index.php?user='+$user;
2cacc6d41bbb37262a98f745aa00fbf0";
}
else{
echo "cbcabc09e924becb49144e0c3123329d
alert('账号密码错误');
window.location.href='../login.php';
2cacc6d41bbb37262a98f745aa00fbf0";
}
$result->free_result();
$conn->close();
?>
这段代码如果登录成功则将数据取出,如果失败将弹出账号密码错误
Sever.php:
c696bceb518a47e82af6e08b55d75065connect_error){
die("连接失败:".$conn->connect_error);
}
//echo "连接成功";
?>
此段代码为数据库连接代码
数据库创建语句
/*
Navicat MySQL Data Transfer
Source Server : stu1
Source Server Version : 50505
Source Host : localhost:3306
Source Database : shop_center
Target Server Type : MYSQL
Target Server Version : 50505
File Encoding : 65001
Date: 2021-04-29 18:57:52
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `dingdan`
-- ----------------------------
DROP TABLE IF EXISTS `dingdan`;
CREATE TABLE `dingdan` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopname` varchar(50) DEFAULT NULL,
`price` decimal(8,2) DEFAULT NULL,
`jieshao` varchar(50) DEFAULT NULL,
`img` int(11) DEFAULT NULL,
`count` int(11) DEFAULT NULL,
`sum` int(11) DEFAULT NULL,
`address` varchar(50) DEFAULT NULL,
`name` varchar(25) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of dingdan
-- ----------------------------
INSERT INTO `dingdan` VALUES ('4', '洗面奶', '50.00', '非常好用的洗面奶', '1', '1', null, null, '123');
-- ----------------------------
-- Table structure for `gouwuche`
-- ----------------------------
DROP TABLE IF EXISTS `gouwuche`;
CREATE TABLE `gouwuche` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopname` varchar(25) DEFAULT NULL,
`price` decimal(8,2) DEFAULT NULL,
`jieshao` varchar(50) DEFAULT NULL,
`img` int(2) DEFAULT NULL,
`count` int(10) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
`address` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of gouwuche
-- ----------------------------
INSERT INTO `gouwuche` VALUES ('13', '洗面奶', '50.00', '非常好用的洗面奶', '1', '10', '123', null);
INSERT INTO `gouwuche` VALUES ('14', '护肤液', '60.00', '柔韧肌肤,光泽润肤', '2', '3', '123', null);
INSERT INTO `gouwuche` VALUES ('15', '华为手机', '5000.00', '高品质,曲面屏,刷新快,无卡顿', '7', '2', '123', null);
-- ----------------------------
-- Table structure for `shop`
-- ----------------------------
DROP TABLE IF EXISTS `shop`;
CREATE TABLE `shop` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopname` varchar(25) DEFAULT NULL,
`price` decimal(8,2) DEFAULT NULL,
`jieshao` varchar(50) DEFAULT NULL,
`img` int(2) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of shop
-- ----------------------------
INSERT INTO `shop` VALUES ('1', '洗面奶', '50.00', '非常好用的洗面奶', '1');
INSERT INTO `shop` VALUES ('2', '护肤液', '60.00', '柔韧肌肤,光泽润肤', '2');
INSERT INTO `shop` VALUES ('3', '耳机', '50.00', '蓝牙耳机,超长待机', '3');
INSERT INTO `shop` VALUES ('4', '高品质耳机', '100.00', '音质清晰,高品质无损音质', '4');
INSERT INTO `shop` VALUES ('5', '拖鞋', '20.00', '结实耐用,十分舒适', '5');
INSERT INTO `shop` VALUES ('6', '手机', '980.00', '刷新快,充电两分钟,通话两小时', '6');
INSERT INTO `shop` VALUES ('7', '华为手机', '5000.00', '高品质,曲面屏,刷新快,无卡顿', '7');
INSERT INTO `shop` VALUES ('8', '护发素', '50.00', '滋润头皮,保护头发,让光头变得长发飘飘', '8');
INSERT INTO `shop` VALUES ('9', '苹果手机', '5000.00', '品质高,苹果带给你不一样的体验', '9');
INSERT INTO `shop` VALUES ('10', '行李箱', '280.00', '静音轮,承重能力强,耐磨', '10');
INSERT INTO `shop` VALUES ('11', '牙膏', '18.00', '内含茶多酚,美白牙齿', '11');
INSERT INTO `shop` VALUES ('12', '舒适达牙膏', '28.00', '预防牙齿敏感,美白牙齿,防止牙龈出血', '12');
-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(25) DEFAULT NULL,
`password` varchar(25) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('1', '123', '123');
INSERT INTO `user` VALUES ('2', '', '');
INSERT INTO `user` VALUES ('3', '12121', '212');
以上是php实现登录功能的详细内容。更多信息请关注PHP中文网其他相关文章!