Exemplo n.º 1
0
<?php

$BlogsController = new BlogsController($db, $plural_resorce);
$blog = $BlogsController->edit($_POST, $id);
var_dump($_POST);
?>

<div>
  <form action="" method="post">
    <div>
      <input type="text" name="title" value="<?php 
echo $blog['title'];
?>
">
    </div>
    <div><textarea name="body"><?php 
echo $blog['body'];
?>
</textarea></div>
    <div><input type="submit" value="編集完了"></div>
  </form>
</div>
Exemplo n.º 2
0
//$action(グローバル変数)は、routes.phpで定義されているもの
switch ($action) {
    case 'index':
        $controller->index();
        break;
    case 'show':
        $controller->show($id);
        break;
    case 'add':
        $controller->add();
        break;
    case 'create':
        $controller->create($post['title'], $post['body']);
        break;
    case 'edit':
        $controller->edit($id);
        break;
    case 'update':
        $controller->update($id, $post['title'], $post['body']);
        break;
    case 'delete':
        $controller->delete($id);
        break;
    default:
        break;
}
class BlogsController
{
    //プロパティ
    private $action = '';
    private $resource = '';
Exemplo n.º 3
0
<?php

$BlogsController = new BlogsController($db, $plural_resource);
$blog = $BlogsController->edit($id, $_POST);
var_dump($_POST);
?>

<div>
  <form action="" method="post">
    <div>
      <input type="text" name="title" value="<?php 
echo $blog['title'];
?>
">
    </div>

    <div>
      <textarea name="body"><?php 
echo $blog['body'];
?>
</textarea>
    </div>

    <div>
      <input type="submit" value="編集完了">
    </div>
  </form>
</div>


Exemplo n.º 4
0
<?php

$BlogsController = new BlogsController($db, $table_name, $action);
$blog = $BlogsController->edit($id);
?>

<div>
  <form action="" method="post">
    <div>
      <input type="text" name="title" value="<?php 
echo $blog['title'];
?>
">
    </div>
    <div>
      <textarea name="body"><?php 
echo $blog['body'];
?>
</textarea>
    </div>
    <div>
      <?php 
echo link_to('../index', '&laquo;&nbsp;戻る');
?>
<input type="submit" value="編集完了">
    </div>
  </form>
</div>
Exemplo n.º 5
0
<?php

$BlogsController = new BlogsController($db, $plural_resorce, $option);
$blogs = $BlogsController->show();
$blog = mysqli_fetch_assoc($blogs);
$BlogsController->edit($_POST, $option);
?>

<form action="" method="post" accept-charset="utf-8">
  <label for="title">タイトル</label><br>
  <input type="text" name="title" <?php 
echo Make_value($blog['title']);
?>
><br>
  <?php 
if (isset($_POST['title'])) {
    if ($_POST['title'] == 'empty') {
        echo "<p>* タイトルを入力してください</p>";
    }
}
?>
  <label for="body">本文</label><br>
  <textarea name="body"><?php 
echo $blog['body'];
?>
</textarea><br>
  <?php 
if (isset($_POST['body'])) {
    if ($_POST['body'] == 'empty') {
        echo "<p>* 本文を入力してください</p>";
    }