<?php ?> <div style="margin:10px 0px;border:1px solid red;float:left;width:100%;text-align:center;"> Błędnie podany login lub hasło. </div> <?php } if($_SESSION['auth'] === true) { ?> <div style="margin:10px 0px;float:left;width:100%;text-align:center;"> </div> <?php } else { ?> <form action="" method="post" id="form_reg"> <fieldset> <label for="login"> <span class="label"> Login: </span> <input type="text" name="login" id="login" /> </label> <label for="pass"> <span class="label"> Hasło: </span> <input type="password" name="pass" id="pass" /> </label> </fieldset> <div> <input type="submit" value="Loguj" name="submit_loguj" /> </form> <?php } ?> <?php if($_SESSION['auth'] === true) { ?> <div style="width:100%;text-align:center;margin:4px 0px;"> <button onclick="location.href='/logout';return false;">Wyloguj</button> </div> <?php } ?>
po wykonaniu tego skryptu powinienem mieć możliwość dodawania przetargów :
{if $ok == 1} <div style="border:1px solid green;color:green;width:100%;text-align:center;padding:10px 0px;">Pomyślnie dodano przetarg</div> {/if} {if $did == 1} <div style="border:1px solid green;color:green;width:100%;text-align:center;padding:10px 0px;">Pomyślnie zdezaktywowano przetarg</div> {/if} {if $zalogowany === true}<button onclick="location.href='/dodaj/';return false;">Dodaj przetarg</button>{/if} <table> <tr style="font-weight:bold;text-align:center;"> <td style="background-color:#d5d5d5;padding:3px;"> <strong>Nr sprawy</strong> </td> <td style="background-color:#d5d5d5;padding:3px;"> <strong>Przedmiot przetargu</strong> </td> {if $zalogowany === true} <td style="background-color:#d5d5d5;padding:3px;"> </td> {/if} </tr> {foreach item=p from=$przetargi} <tr style="border:1px solid black;background-color:#{cycle values="f9f9f9,e7e7e7"};"> <td onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'" onclick="location.href='{$server_url}?id={$p.nr}';return false;" style="cursor:pointer;padding:2px;text-align:center;"> {$p.nr_sprawy} </td> <td onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'" onclick="location.href='{$server_url}?id={$p.nr}';return false;" style="cursor:pointer;padding:2px;"> {$p.opis} </td> {if $zalogowany === true} <td> <button onclick="if(confirm('Czy jesteś pewien ?'))location.href='/przetargi/?did={$p.nr}';return false;">Usuń</button> </td> {/if} </tr> {/foreach} </table>
a tu przedstawiam klasy :
class User extends Base { public $dane; public function __construct() { parent::__construct(); } public function __destruct(){} public function logowanie($login,$pass) { $conn = new Connection(); if(($row = $conn->return_row('SELECT login FROM '.$this->_table_user.' WHERE aktywne = 1 AND login LIKE "'.$login.'" AND pass LIKE "'.md5($pass).'"')) !== false) { $this->setLogowanie($row); } } private function setLogowanie($var) { $_SESSION['login'] = $var['login']; $_SESSION['auth'] = true; } public function logout() { $_SESSION['login'] = ''; $_SESSION['auth'] = false; } public function auth() { return (bool)$_SESSION['auth']; } } ?>