-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
board2 (平井杏子) #20
Open
kyoko-hirai
wants to merge
7
commits into
yrglm-tech-aca:master
Choose a base branch
from
kyoko-hirai:working
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
board2 (平井杏子) #20
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
901fc32
'firt'
kyoko-hirai 61f6d5e
'login,logout'
kyoko-hirai d6e97fc
'board2'
kyoko-hirai 98f3ffc
'board2'
kyoko-hirai ee5b186
eccube start
kyoko-hirai 23199d9
'新着情報機能に表示期間追加'
kyoko-hirai 4db3c51
''
kyoko-hirai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
try { | ||
$pdo=new PDO('mysql:host=localhost;dbname=board1_db;charset=utf8','root', ''); | ||
} catch ( PDOException $e ) { | ||
print "接続エラー:{$e->getMessage()}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: kyoko | ||
* Date: 2017/12/05 | ||
* Time: 18:05 | ||
*/ | ||
$name=$_POST['name']; | ||
$contents=$_POST['contents']; | ||
|
||
if($name==''){ | ||
session_start(); | ||
$_SESSION['error']='名前を入れてください'; | ||
header('Location: http://localhost/tech-aca5_kyoko_hirai/board1/show.php'); | ||
exit; | ||
}elseif($contents==''){ | ||
session_start(); | ||
$_SESSION['error']='投稿を入力してください'; | ||
header('Location: http://localhost/tech-aca5_kyoko_hirai/board1/show.php'); | ||
exit; | ||
}else{ | ||
$_SESSION['error']=null; | ||
//接続 | ||
require('db_connection.php'); | ||
|
||
try { | ||
//insert | ||
$stt = $pdo->prepare("insert into post_table(name, contents) values(:name, :contents)"); | ||
$stt->bindValue(':name', $name); | ||
$stt->bindValue(':contents', $contents); | ||
$stt->execute(); | ||
} catch (PDOException $e) { | ||
print "エラー:{$e->getMessage()}"; | ||
} | ||
|
||
//接続を切る | ||
$pdo = null; | ||
|
||
header('Location: http://localhost/tech-aca5_kyoko_hirai/board1/show.php'); | ||
exit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!doctype html> | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>ESS1</title> | ||
</head> | ||
<body> | ||
<h2>掲示板1</h2><br> | ||
<?php | ||
session_start(); | ||
//var_dump($_SESSION['error']); | ||
if (isset($_SESSION['error'])){ | ||
print $_SESSION['error']; | ||
} | ||
?> | ||
<form method="post" action="insert.php"> | ||
名前:<input type="text" name="name"><br> | ||
投稿:<br> | ||
<textarea name="contents" row="8" cols="40"></textarea><br> | ||
<input type="submit"> | ||
</form> | ||
|
||
</body> | ||
</html> | ||
|
||
<?php | ||
//接続 | ||
require('db_connection.php'); | ||
|
||
try { | ||
$statement = $pdo->query("select * from post_table"); | ||
//var_dump($stt); | ||
foreach ($statement as $row) { | ||
echo $row['id'].':'.$row['name'].'<br>'; | ||
echo $row['contents']; | ||
echo '<br>'; | ||
//var_dump($row); | ||
} | ||
} catch ( PDOException $e ) { | ||
print "エラー:{$e->getMessage()}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
try { | ||
$pdo=new PDO('mysql:host=localhost;dbname=board2_db;charset=utf8','root', ''); | ||
} catch ( PDOException $e ) { | ||
print "接続エラー:{$e->getMessage()}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
require_once './smarty/Smarty.class.php'; | ||
|
||
$smarty = new Smarty(); | ||
$smarty -> template_dir = 'templates/'; | ||
$smarty -> compile_dir = 'templates_c/'; | ||
|
||
|
||
if (isset($_POST['login'])){ | ||
|
||
$name = $_POST['name']; | ||
$password = $_POST['password']; | ||
|
||
|
||
if ($name === '') { | ||
|
||
$smarty -> assign('error' , 'ユーザー名を入力してください'); | ||
|
||
} elseif ($password === '') { | ||
|
||
$smarty -> assign('error' , 'パスワードを入力してください。'); | ||
|
||
}else{ | ||
|
||
try { | ||
|
||
require('db_connection.php'); | ||
|
||
|
||
$users = $pdo->query("SELECT * from member_table"); | ||
|
||
session_start(); | ||
$_SESSION['username'] = null; | ||
$_SESSION['id'] = null; | ||
$smarty -> assign('error' , 'ユーザ名かパスワードが違います。'); | ||
|
||
foreach ($users as $user) { | ||
|
||
if($name === $user['name'] and $password === $user['password']) { | ||
|
||
$_SESSION['username'] = $user['name']; | ||
$_SESSION['id'] = $user['id']; | ||
header('Location: ./show.php'); | ||
exit; | ||
|
||
} | ||
//var_dump($_SESSION['username']); | ||
} | ||
} catch (PDOException $e) { | ||
echo $e->getMessage(); | ||
} | ||
} | ||
} | ||
|
||
$smarty->display('login.html'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
session_start(); | ||
$_SESSION['username']=null; | ||
$_SESSION['id']=null; | ||
header('Location: ./show.php'); | ||
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
require_once './smarty/Smarty.class.php'; | ||
|
||
$smarty = new Smarty(); | ||
$smarty -> template_dir = 'templates/'; | ||
$smarty -> compile_dir = 'templates_c/'; | ||
|
||
|
||
require('db_connection.php'); | ||
|
||
if(isset($_POST['update'])){ | ||
|
||
try{ | ||
|
||
$post = $pdo->prepare('UPDATE post_table set contents=:contents where id = :id'); | ||
$post -> bindValue(':id' ,(int) $_POST['id'], PDO::PARAM_INT); | ||
$post -> bindValue(':contents' ,$_POST['contents']); | ||
$post -> execute(); | ||
header('Location: ./show.php'); | ||
exit; | ||
|
||
} catch ( PDOException $e ) { | ||
print "エラー:{$e->getMessage()}"; | ||
} | ||
|
||
}elseif (isset($_POST['delete'])){ | ||
|
||
try{ | ||
|
||
$post = $pdo->prepare('DELETE FROM post_table where id = :id'); | ||
$post -> bindValue(':id' ,(int) $_POST['id'], PDO::PARAM_INT); | ||
$post -> execute(); | ||
header('Location: ./show.php'); | ||
exit; | ||
|
||
} catch ( PDOException $e ) { | ||
print "エラー:{$e->getMessage()}"; | ||
} | ||
|
||
}else{ | ||
|
||
try{ | ||
|
||
$post = $pdo->prepare('SELECT contents FROM post_table where id = :id'); | ||
$post -> bindValue(':id' ,(int) $_POST['id'], PDO::PARAM_INT); | ||
$post -> execute(); | ||
$contents = $post -> fetch(); | ||
|
||
} catch ( PDOException $e ) { | ||
print "エラー:{$e->getMessage()}"; | ||
} | ||
$smarty->assign('id', $_POST['id']); | ||
$smarty->assign('contents', $contents); | ||
} | ||
|
||
$smarty->display('post_update.html'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
require_once './smarty/Smarty.class.php'; | ||
|
||
$smarty = new Smarty(); | ||
$smarty -> template_dir = 'templates/'; | ||
$smarty -> compile_dir = 'templates_c/'; | ||
|
||
session_start(); | ||
|
||
if(isset($_POST['insert'])) { | ||
|
||
$id = $_SESSION['id']; | ||
$contents = $_POST['contents']; | ||
|
||
|
||
if ($contents == '') { | ||
|
||
$smarty->assign('error', '投稿を入力してください'); | ||
|
||
} else { | ||
|
||
require('db_connection.php'); | ||
|
||
try { | ||
|
||
//insert | ||
$post = $pdo->prepare("insert into post_table(user_id, contents) values(:user_id, :contents)"); | ||
$post->bindValue(':user_id', $id); | ||
$post->bindValue(':contents', $contents); | ||
$post->execute(); | ||
|
||
} catch (PDOException $e) { | ||
print "エラー:{$e->getMessage()}"; | ||
} | ||
|
||
//接続を切る | ||
$pdo = null; | ||
|
||
} | ||
} | ||
|
||
|
||
if(isset($_SESSION['username'])) { | ||
$smarty -> assign('name',$_SESSION['username']); | ||
} | ||
|
||
require('db_connection.php'); | ||
|
||
try { | ||
|
||
$posts = $pdo->query("select * from post_table"); | ||
$posts = $posts ->fetchAll(PDO::FETCH_ASSOC); | ||
|
||
foreach ($posts as $post) { | ||
|
||
//post_tableのuser_idからmember_tableのnameを引き出す | ||
$sql = 'SELECT name FROM member_table where id = :user_id'; | ||
$name = $pdo->prepare($sql); | ||
$name -> bindValue(':user_id' ,(int) $post['user_id'], PDO::PARAM_INT); | ||
$name -> execute(); | ||
$username = $name -> fetch(PDO::FETCH_ASSOC); | ||
//var_dump($username); | ||
|
||
$post['name'] = $username['name']; | ||
|
||
$allposts[] = array($post); | ||
} | ||
|
||
//var_dump($allposts); | ||
$smarty -> assign('posts',$allposts); | ||
|
||
|
||
if(isset($_SESSION['id'])) { | ||
$smarty->assign('user_id', $_SESSION['id']); | ||
} | ||
|
||
} catch ( PDOException $e ) { | ||
print "エラー:{$e->getMessage()}"; | ||
} | ||
|
||
|
||
$smarty->display('show.html'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requireはファイルの戦闘にまとめてかくようにして、何をつかっているかまとめて管理できるようにしときましょう。