generated from teknasyon-bootcamp/homework5
-
Notifications
You must be signed in to change notification settings - Fork 4
/
post-edit.php
65 lines (54 loc) · 1.7 KB
/
post-edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
require "vendor/autoload.php";
$config = require "config.php";
$engine = $config['engine'];
$host = $config['host'];
$user = $config['user'];
$pass = $config['password'];
$log_type = $config['logging'];
$log_file_dir = __DIR__."/storage/logs/logs.log";
use App\DB\Engine\Mysql;
use App\DB\Engine\MongoDB;
use App\Db\Database;
use App\Logger\Driver\Database as LoggerDatabase;
use App\Logger\Driver\File;
use App\Logger\Logger;
use App\Logger\LoggableInterface;
if ($engine == "mysql") {
$driver = new Mysql($host, $user, $pass, "book_app");
} elseif ($engine =="mongodb") {
$driver = new MongoDB("", "", "", "", "", []);
}
if($log_type =="file"){
$logger = new Logger(new File($log_file_dir));
}else{
$logger = new Logger(new LoggerDatabase($driver));
}
try{
$db = new Database();
$db->setDriver($driver);
}catch (Exception $e){
$logger->log($e, LoggableInterface::ERROR);
}
try{
$post = $db->find("posts",$_GET['id']);
}catch (Exception $e){
$logger->log($e,LoggableInterface::ERROR);
}
$post_value = $post['post'];
?>
<?php include "_shared/header.php";?>
<div class="container">
<h1>Post Düzenleme Sayfası</h1>
<form action='post-update.php' method='GET'>
<div class='form-group'>
<div >
<input type="hidden" name="id" value='<?=$_GET['id']??'' ?>'>
<label for='post'>Post</label>
<textarea name="post" rows="10" cols="100" style="resize: none" class='form-control' > <?= $post_value??''?></textarea>
</div>
<button class = 'btn btn-primary mt-3'>Gönder</button>
</div>
</form>
</div>
<?php include "_shared/footer.php";?>