<div class="col-sm-offset-1 col-sm-10"> <button type="submit" class="btn btn-default" name="submit">Добавить</button> </div> </div> </form> </div> </div> </div> <div class="panel"> <div class="panel-body"> <!--/stories--> <?php/* if(!empty($_SESSION['error'])):?> <?php echo '<p style="text-align: center;">'.$_SESSION['error'].'</p>'?> <?php unset($_SESSION['error']); ?> <?php endif;*/?> <?php $newses = Golos::findAll();?> <?php foreach ($newses as $key): ?> <?php $avtors = $key->avtor; ?> <?php $id = $key->id;?> <?php $text = $key->text;?> <div class="row"> <br> <p><?php echo $id;?></p> <div class="col-md-12 col-sm-9" style="border:1px solid #ccc;"> <h3><?php echo $key->title; ?></h3>
<?php //session_start(); require_once __DIR__ . '/../function.php'; require_once __DIR__ . '/../autoload.php'; /*if(empty($_POST['title_news']) || empty($_POST['text_news'])) { $_SESSION['error'] = 'На заполнены поля!'; header('Location: /logon.php'); exit; } */ $name = $_POST['title_golos']; $text = $_POST['text_golos']; $date = date("F j, Y, g:i a"); $avtor = getUser(); $b = new Golos(); $b->insert($name, $text, $avtor); header('location: /../views/golos.php'); /** * Created by PhpStorm. * User: Александр * Date: 27.10.2015 * Time: 20:36 */
<?php require_once __DIR__ . '/../function.php'; require_once __DIR__ . '/../autoload.php'; if (!empty($_GET['i']) && !empty($_GET['id'])) { $golosa = Golos::findAll(); foreach ($golosa as $value) { $golos = $value->golos; $id = $value->id; if (get_id() == $id) { ++$golos; $memory = new Golos(); $memory->updateById($id, $golos); } } } header('location: /../views/golos.php');