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
## 6f813dd33230812ecea7ca1e099ce1faquery($sql);
if($result->num_rows>0){
$row=$result->fetch_assoc();//從結果集中取出一數組
echo json_encode( $row);//轉成json格式
session_start();
$_SESSION['name']=$user;
echo "85892338dea33e2daa35f4b67e3bcc9b
window.location.href='../index.php?user=' $user;
2cacc6d41bbb37262a98f745aa00fbf0";
#
}
else{
echo "7c6ecc2a75ade4ffa1f50134f6be3b0e
alert('帳號密碼錯誤' );
window.location.href='../login.php';
#2cacc6d41bbb37262a98f745aa00fbf0";
}
$ result->free_result();
$conn->close();
?>
這段程式碼如果登入成功則會將資料取出,如果失敗將彈出帳號密碼錯誤
Sever.php:
ba575044156f9bce68a72e06ecc7f336connect_error){
#die("連線失敗:".$conn->connect_error);
}
#//echo "連線成功";
?>
#此段程式碼為資料庫連線代碼
資料庫建立語句
/*
Navicat MySQL Data Transfer
/*Navicat MySQL Data Transfer Source Server : stu1Source Server Version : 50505Source Host : localhost:3306Source Database
##Target Server Version : 50505
File Encoding : 65001
#Date: 2021-04-29 18:#
Date: 2021-04-29 18:57:
## */ 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,# `sum` int(11) DEFAULT NULL, `address` varchar(50) DEFAULT NULL, `name` varchar(25) DEFAULT NULL, PRIMARY KEY (`id`)##C
) 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,
##卷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,
`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=# 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中文網其他相關文章!