公司在百度做网站找谁关键词排名规则

当前位置: 首页 > news >正文

公司在百度做网站找谁,关键词排名规则,腾讯云市场 wordpress,小说网站如何做seo关键词一、连接数据库基本函数 mysqli_connect(); 作用#xff1a;创建数据库连接#xff0c;打开一个新的mysql的连接。传参顺序#xff1a;数据库地址、数据库账号、数据库密码
?phpecho mysqli_connect(localhost,root,root) ?
/*结果#xff1a;F… 一、连接数据库基本函数 mysqli_connect(); 作用创建数据库连接打开一个新的mysql的连接。传参顺序数据库地址、数据库账号、数据库密码
?phpecho mysqli_connect(localhost,root,root) ?
/结果Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in C:\Users\Administrator\Desktop\网络安全\php\project_01\php_connect.php:2 Stack trace: #0 {main} thrown in C:\Users\Administrator\Desktop\网络安全\php\project_01\php_connect.php on line 2/寻错 翻译错误为致命错误未捕获错误调用未定义的函数mysqli_connect出现错误原因未配置php.ini 解决方法 参考https://blog.csdn.net/sxudong2010/article/details/83277285 重新测试连接 ?php \(connmysqli_connect(localhost,root,root); if(\)conn){echook; }else{echoerror; } //phpinfo(); ? 效果图 mysqli_select_db 作用选择需要的数据库传参顺序mysqli对象数据库名
mysqli_select_db($conn, php); #选择名为php的数据库mysqli_query 作用可以对数据库中的表进行增删改查传参顺序mysqli对象SQL语句

修改编码

mysqli_query($conn, SET NAMES utf8);

$GLOBALS是将conn变量赋予全局属性

查询user表中userName字段为abc的数据

返回值为mysqli_result对象

mysqli_query($GLOBALS[conn], select * from user where userName abc) mysqli_fetch_row和mysqli_fetch_all() 区别 row()只返回一条数据适合有条件的查询如返回Array时为一维数组all返回查询到的所有数据使用列表展示功能如返回Array时为二维数组 作用接收查询数据并并以多种形式返回传参顺序mysqli_result对象

参数为mysqli_query()函数返回的 mysqli_result对象

返回结果为Array

echo mysqli_fetch_all( mysqli_query(\(GLOBALS[conn], select * from user )) echo mysqli_fetch_row( mysqli_query(\)GLOBALS[conn], select * from user where userName123)) 二、案例实现 1、功能说明 该案例主要功能为用户登录和修改密码功能
2、涉及知识 php变量作用域的范围php对于Session的存储、修改和销毁php对于字符串Base64编码和解码的应用php对于字符串判空、去空、去特殊值的处理php对于Mysql的如何连接、选择数据库、增删改查等功能
3、页面分布 index.php登录页index.php个人中心页register.php注册页db.php对于数据库一系列操作utril.php工具方法style.css页面通用css样式
4、db.php ?php

创建一次新的mysql连接

$conn mysqli_connect(localhost, root, root) or dir(数据库连接失败);

var_dump($conn);

#连接上名为php的数据库 mysqli_select_db($conn, php);

修改编码

mysqli_query(\(conn, SET NAMES utf8); /*** 判断用户是否存在* \)name用户名* return:返回存在的数据数组* */ function isQueryUserName(\(name){return mysqli_fetch_row( mysqli_query(\)GLOBALS[conn], select * from user where userName \(name)); } /** 更新密码* \)userName用户名* \(password 密码* */ function updatePassword(\)userName,\(password){\)password base64_encode(\(password);return mysqli_query(\)GLOBALS[conn], update user set password \(password where userName \)userName); }?5、util.php ?php /判断数据是否为空 / function isEmpty(\(value){return !empty(\)value)?true:false; } /** 去除多余格式 trim去除左右两边空格* stripslashes去除反斜杠* htmlspecialchars把预定义的字符转换为 HTML 实体* 预定义的字符是和号成为 amp; 双引号成为 quot; 单引号成为 小于成为 lt; 大于成为 gt;** / function outFormat(\(value){\)value trim(\(value);\)value stripslashes(\(value);\)value htmlspecialchars(\(value);return \)value;}// echo base64_encode(admin); // 编码# echo base64_decode(dmFyaW4); // 解码 /** 匹配8位由大写或小写或数字 */ function passwordReg(\(password){return preg_match(/^[a-zA-Z0-9]{8}\)/, $password); } 6、style.css *{padding:0px;margin:0px; } .box{margin: 100px auto;background: linear-gradient(135deg, #d3e4f5, #0088a9, #00c9a7, #92d5c6, #ebf5ee) repeat-x ;width:600px;height:500px;border:1px solid #f5f5f5;border-radius: 15px;box-shadow: 10px 10px 10px #f5f5f5;color: white; } h2{text-align: center;margin: 20px 0px; } label{margin: 20px 0px;display: inline-table; } form{text-align: center; } input{color: black; }7、login.php 代码 ?php# 开启sessionsession_start();

包含

include ./db.php; include ./util.php; \(userName\)password;

检测

if(isset(\(_POST[loginSubmit])){\)userName outFormat( \(_POST[userName]);\)password outFormat(\(_POST[password]);# 判空if(isEmpty(\)userName) isEmpty(\(password)){# 查询\)userInfoArray isQueryUserName(\(userName);# 比对数据if(\)userInfoArray!null \(userInfoArray[1] \)userName base64_decode(\(userInfoArray[2]) \)password){echo scriptalert(登录成功);/script;# 存session\(_SESSION[userName]\)userName;// echo \(_SESSION[userName];echo scriptwindow.location.hrefindex.php;/script;}else{echo scriptalert(用户信息错误请重试);/script;}}else{echo scriptalert(请将信息填写完整);/script;} }?!DOCTYPE htmlhtml langenheadmeta charsetUTF-8titleLogin/titlelink href./style.css typetext/css relstylesheet/headbodydiv classboxh2登录/h2form action./login.php methodPOSTlabel 用户名input typetext nameuserName value?php echo \)userName?/labelbrlabel 密nbsp;nbsp; nbsp;码input typepassword namepassword value?php echo \(password?/labelbrinput typesubmit nameloginSubmit value登录 stylewidth:60px;height: 30px;color: black;margin-top: 100pxbrp stylemargin-top: 20px;color: black;font-size: 14px 请a href# stylecolor: green注册/a/p/form/div/body/html效果 8、index.php 代码 ?phpsession_start();include ./db.php;include ./util.php;\)userName\(password\)confirmPassword;\(userName\)_SESSION[userName];if(\(userNamenull){echo scriptwindow.location.hreflogin.php;/script;}\)password base64_decode(isQueryUserName(\(userName)[2]);if(isset(\)_POST[updateSubmit])){\(password \)_POST[password];\(confirmPassword \)_POST[confirmPassword];echo \(password;echo \)confirmPassword;if(isEmpty(\(password) isEmpty(\)confirmPassword)){if(passwordReg(\(password) \)password \(confirmPassword){if (updatePassword(\)userName, \(password)true) {echo scriptalert(用户密码更新成功 )/script;session_destroy();echo scriptwindow.location.hreflogin.php;/script;}}else{echo scriptalert(密码格式错误请重试)/script;}}else{echo scriptalert(请将信息填写完整)/script;}} ? !DOCTYPE html html langen headmeta charsetUTF-8title个人中心/titlelink href./style.css typetext/css relstylesheet /head body div classboxh2个人中心/h2form action# methodpostlabel 欢迎您span stylefont-weight: bold ?php echo \)userName?/span/labelbrlabel 密nbsp;nbsp; nbsp;码input typepassword namepassword value?php echo \(password?/labelbrlabel 确认密码input typepassword nameconfirmPassword value?php echo \)confirmPassword ?/labelbrinput typesubmit nameupdateSubmit value修改 stylewidth:60px;height: 30px;color: black;margin-top: 100pxbr/form /div/body /html效果 9、register.php 注注册页面并为实现注册功能大致功能代码与index.php页面类似。 !DOCTYPE html html langen headmeta charsetUTF-8titleLogin/titlelink href./style.css typetext/css relstylesheet/head body div classboxh2注册/h2form action# methodpostlabel 用户名input typetext nameuserName value用户名/labelbrlabel 密nbsp;nbsp; nbsp;码input typepassword namepassword value密码/labelbrinput typesubmit nameloginSubmit value登录 stylewidth:60px;height: 30px;color: black;margin-top: 100pxbrp stylemargin-top: 20px;color: black;font-size: 14px 请a href# stylecolor: green注册/a/p/form /div/body /html