Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 167c28f

Browse files
案例blog,日常更新
1 parent e762ca0 commit 167c28f

File tree

7 files changed

+126
-154
lines changed

7 files changed

+126
-154
lines changed

‎.idea/workspace.xml‎

Lines changed: 111 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎php-mysql/blog/class/system.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ function SetInfo(){
3232
if($this->site_name == ''){
3333
$this->site_name = '小小梦工场的网站';
3434
}
35+
// setcookie('site_name',$this->site_name,time()+60*60*24*7);
3536
define('SITE_NAME',$this->site_name,TRUE);
3637
if($this->site_owner == ''){
3738
$this->site_owner = '小小梦工场';
3839
}
3940
define('SITE_OWNER',$this->site_owner,TRUE);
41+
// setcookie('site_owner',$this->site_owner,time()+60*60*2487);
4042
}
4143
}
4244
$system_info = new SystemInfo();

‎php-mysql/blog/controller/get_home_data.php‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
* Date: 2016年11月4日
66
* Time: 22:40
77
*/
8-
require '../blog/class/conn.php';
8+
//require '../blog/class/conn.php';
99

1010
class getData{
1111
public $user_info;
1212
function get_data($username){
13-
$sys_conn = new ConnDB();
14-
$sys_conn->conn_db('localhost','root','','blog');
15-
$conn = $sys_conn->GetConn();
13+
$sys_conn1 = new ConnDB();
14+
$sys_conn1->conn_db('localhost','root','','blog');
15+
$conn = $sys_conn1->GetConn();
1616
mysqli_query($conn,"set names 'utf8' ");
1717
$sql = mysqli_query($conn," select *from users where username='$username'");
1818
$this->user_info = mysqli_fetch_array($sql);
19+
$sys_conn1->CloseConn();
1920
}
2021
function get_user_name(){
2122
echo $this->user_info['username'];
@@ -32,8 +33,4 @@ function get_user_id(){
3233
}
3334
$home_data = new getData();
3435
$home_data->get_data($_COOKIE['username']);
35-
36-
37-
38-
39-
36+
echo $_COOKIE['username'];

‎php-mysql/blog/controller/login_ok.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
if($user_pwd == $info[0]){
1919
$sql1 = mysqli_query($conn," select username from users where email='$user_email'");
2020
$info1 = mysqli_fetch_array($sql1);
21-
define('USERNAME',$info1[0],true);
22-
setcookie('username',$info1[0],time()+60*60*24*7);
21+
// define('USERNAME',$info1[0],true);
22+
setcookie('username',$info1[0],time()+60*60*24*7,'/','php-learning.dev',1);
2323
// echo $info1[0];
24+
echo $_COOKIE['username'];
2425
echo "<script>;window.location.href= '/php-mysql/blog/index.php';</script>";
2526
}else{
2627
echo "<script>alert('请重新填写密码!');</script>";

‎php-mysql/blog/controller/register_ok.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
$user_description = $_POST['user-description'];
1717
$user_pwd = $_POST['user-pwd'];
1818
$info = mysqli_query($conn,"insert into users(username,password,email,avatar,description) VALUES ('$username','$user_pwd','$user_email','images/avatar/avatar.JPG','$user_description') ");
19+
$sys_conn->CloseConn();
1920
if($info){
2021

2122
echo "<script> alert('恭喜你,注册成功!');window.location.href= '/php-mysql/blog/index.php';</script> ";
2223
}
23-
$sys_conn->CloseConn();

‎php-mysql/blog/header.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
* Time: 23:51
77
*/
88
//网站header
9-
require 'controller/get_home_data.php';
9+
//require 'controller/get_home_data.php';
1010
?>
1111
<div class="header col-md-12">
1212
<div class="col-md-10 col-md-offset-1">
1313
<span class="site-name pull-left">
14-
<a href="index.php"> <?php echo SITE_NAME ?></a>
14+
<a href="index.php"> <?php echo $_COOKIE['site_name'] ?></a>
1515
</span>
1616
<span class="pull-right">
1717
<?php
1818
if(!isset($_COOKIE['username'])){
19-
echo "<a href='space/$home_data->get_user_id()'>$home_data->get_user_name()</a>";
19+
echo "<a href='/#'>".$_COOKIE['username']."</a>";
2020
}else{
2121
echo "<a href=\"login.php\">登录</a><a href=\"register.php\">注册</a>";
2222
}

‎php-mysql/blog/index.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88
require 'class/system.php';
99
require 'controller/get_home_data.php';
10-
1110
//主页
1211
?>
1312
<!DOCTYPE html>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /