Skip to content

Commit

Permalink
增加前端用户登陆/注册/评论功能
Browse files Browse the repository at this point in the history
  • Loading branch information
kangvcar committed Nov 5, 2018
1 parent 7f9abed commit b57e5f9
Show file tree
Hide file tree
Showing 194 changed files with 52,408 additions and 36 deletions.
68 changes: 68 additions & 0 deletions front-end/LoginAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
if (isset($_GET['action'])) {
if ($_GET['action'] == 'logout') {
session_start();
unset($_SESSION['lid']);
unset($_SESSION['lusername']);
header("Location:index.php");
exit();
}
}
if (isset($_POST['LoginSubmit'])) {
$loginname = $_POST['username'];
$loginpasswd = $_POST['password'];

include("dbconnection.php");
print("$loginname");
print("$loginpasswd");
$loginchecksql = "SELECT uid, username, password FROM user WHERE username='$loginname' AND password='$loginpasswd';";
$result15 = $conn->query($loginchecksql);
if ($result15->num_rows > 0) {
// 登录成功
$row = $result15->fetch_row();
session_start();
$_SESSION['lid'] = $row[0];
$_SESSION['lusername'] = $loginname;
header("Location:index.php");
exit();
}else{
print <<<EOF
<br>
<div class="alert alert-dismissable alert-danger" align="center">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Warning!</strong> 登录失败!
</div>
EOF;

}
}
if (isset($_POST['registerSubmit']) and (empty($_POST['registername']) or empty($_POST['registerpassword']))){
print <<<EOK
<br>
<div class="alert alert-dismissable alert-danger" align="center">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Warning!</strong> 用户名或密码不能为空!
</div>
EOK;
}elseif (isset($_POST['registerSubmit']) and !empty($_POST['registername']) and !empty($_POST['registerpassword'])) {
$registername = $_POST['registername'];
$registerpassword = $_POST['registerpassword'];
$registeremail = $_POST['registeremail'];
include("dbconnection.php");
$registerusersql = "INSERT INTO user(username, password, email) VALUES ('$registername', '$registerpassword', '$registeremail');";
$conn->query($registerusersql);
if ($conn->affected_rows > 0) {
print <<<EOW
echo "<script language=javascript>alert('注册成功!');location.href='LoginMain.php';</script>";
EOW;
}else{
print <<<EOQ
<br>
<div class="alert alert-dismissable alert-danger" align="center">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Warning!</strong> 注册失败!用户名已存在!
</div>
EOQ;
}
}
?>
13 changes: 13 additions & 0 deletions front-end/LoginForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1 align="center" class="text-center text-info">用户登录</h1><br>
<form role="form" action="" method="POST">
<div class="form-group">
<label for="exampleInputEmail1">用户名</label><input name="username" type="text" class="form-control" id="exampleInputEmail1" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">密码</label><input name="password" type="password" class="form-control" id="exampleInputPassword1" />
</div>
<button type="submit" name="LoginSubmit" class="btn btn-success btn-block">登陆</button>
<button type="submit" name="registerSubmit" class="btn btn-success btn-block">注册</button>
<br>
<div align="right"><a href="index.php"><< 以游客身份访问</a></div>
</form>
32 changes: 32 additions & 0 deletions front-end/LoginMain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>用户登录</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="bootstrap-3.0.1/dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.0.1/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row clearfix">
<div class="col-md-4 column">
</div>
<div class="col-md-4 column">
<br><br><br><br><br><br>
<?php
if (isset($_POST['registerSubmit'])) {
include("registerForm.php");
}else{
include("LoginForm.php");
}
include("LoginAction.php");
?>
</div>
<div class="col-md-4 column">
</div>
</div>
</div>
<script type="text/javascript" src="bootstrap-3.0.1/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="bootstrap-3.0.1/jquery/jquery-3.3.1.min.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions front-end/bootstrap-3.0.1/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
41 changes: 41 additions & 0 deletions front-end/bootstrap-3.0.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Ignore docs files
_gh_pages
_site
.ruby-version

# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.zip
*.vi
*~

# OS or Editor folders
.DS_Store
._*
Thumbs.db
.cache
.project
.settings
.tmproj
*.esproj
nbproject
*.sublime-project
*.sublime-workspace
.idea

# Komodo
*.komodoproject
.komodotools

# grunt-html-validation
validation-status.json
validation-report.json

# Folders to ignore
node_modules
11 changes: 11 additions & 0 deletions front-end/bootstrap-3.0.1/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js:
- 0.8
before_script:
- gem install jekyll
- npm install -g grunt-cli
env:
global:
- secure: Besg41eyU+2mfxrywQ4ydOShMdc34ImaO0S0ENP+aCOBuyNBIgP59wy5tBMmyai2/8eInYeVps4Td96mWInMMxzTe3Bar7eTLG5tWVKRSr/wc4NBPZ/ppoPAmCEsz9Y+VptRH9/FO8n7hsL9EFZ+xBKbG+C0SccGoyBDpA5j7/w=
- secure: Ptiv7phCImFP3ALIz+sMQzrZg8k7C1gLZbFBhWxjnQr3g06wIfX3Ls5y9OHvxid+lOZZjISui3wzBVgpVHqwHUYf96+r0mo6/mJ+F4ffUmShZANVaIMD/JRTnXhUQJbvntGLvxn1EYWPdNM+2IHJrMipnjHxU9tkgAnlel4Zdew=
- TWBS_HAVE_OWN_BROWSERSTACK_KEY: ""
1 change: 1 addition & 0 deletions front-end/bootstrap-3.0.1/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
getbootstrap.com
61 changes: 61 additions & 0 deletions front-end/bootstrap-3.0.1/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Contributing to Bootstrap

Looking to contribute something to Bootstrap? **Here's how you can help.**



## Reporting issues

We only accept issues that are bug reports or feature requests. Bugs must be isolated and reproducible problems that we can fix within the Bootstrap core. Please read the following guidelines before opening any issue.

1. **Search for existing issues.** We get a lot of duplicate issues, and you'd help us out a lot by first checking if someone else has reported the same issue. Moreover, the issue may have already been resolved with a fix available.
2. **Create an isolated and reproducible test case.** Be sure the problem exists in Bootstrap's code with a [reduced test case](http://css-tricks.com/reduced-test-cases/) that should be included in each bug report.
3. **Include a live example.** Make use of jsFiddle or jsBin to share your isolated test cases.
4. **Share as much information as possible.** Include operating system and version, browser and version, version of Bootstrap, customized or vanilla build, etc. where appropriate. Also include steps to reproduce the bug.



## Pull requests

- CSS changes must be done in `.less` files first, never just the compiled `.css` files
- If modifying the `.less` files, always recompile and commit the compiled files `bootstrap.css` and `bootstrap.min.css`
- Try not to pollute your pull request with unintended changes--keep them simple and small
- Try to share which browsers your code has been tested in before submitting a pull request
- Pull requests should always be against the `master` branch, never against `gh-pages`.



## Coding standards

### HTML

- Two spaces for indentation, never tabs
- Double quotes only, never single quotes
- Always use proper indentation
- Use tags and elements appropriate for an HTML5 doctype (e.g., self-closing tags)
- Use CDNs and HTTPS for third-party JS when possible. We don't use protocol-relative URLs in this case because they break when viewing the page locally via `file://`.

### CSS

- Adhere to the [RECESS CSS property order](http://markdotto.com/2011/11/29/css-property-order/)
- Multiple-line approach (one property and value per line)
- Always a space after a property's colon (e.g., `display: block;` and not `display:block;`)
- End all lines with a semi-colon
- For multiple, comma-separated selectors, place each selector on its own line
- Attribute selectors, like `input[type="text"]` should always wrap the attribute's value in double quotes, for consistency and safety (see this [blog post on unquoted attribute values](http://mathiasbynens.be/notes/unquoted-attribute-values) that can lead to XSS attacks).

### JS

- No semicolons
- Comma first
- 2 spaces (no tabs)
- strict mode
- "Attractive"



## License

With v3.1, we're moving from the Apache 2 to the MIT license for the Bootstrap code (not the docs). We're in the process of collecting permissions from all Bootstrap contributors with code still part of the project to make this happen. For details, please see [#2054](https://github.com/twbs/bootstrap/issues/2054).

By contributing your code, you agree to dual-license your contribution under the [Apache 2](https://github.com/twbs/bootstrap/blob/master/LICENSE) and [MIT](https://github.com/twbs/bootstrap/blob/master/MIT) licenses.
Loading

0 comments on commit b57e5f9

Please sign in to comment.