function changeRecord($id) { $ath = sqlGet("SELECT * FROM goods WHERE id = " . $id . ";", $id); echo '<form action="edit_record.php" method = "post">'; echo '<table>'; echo '<input type="hidden" name="id" value="' . $ath[0]['id'] . '"/>'; echo '<tr><td>Название товара*: </td><td><input type="text" size="30" name="name" value="' . $ath[0]['name'] . '"/></td></tr>'; echo '<tr><td>Описание товара: </td><td><input type="text" size="30" name="description" value="' . $ath[0]['description'] . '"/></td></tr>'; echo '<tr><td>Цена: </td><td><input type="text" size="30" name="price" value="' . $ath[0]['price'] . '"/></td></tr>'; echo '<tr><td>Картинка: </td><td><input type="text" size="30" name="pic" value="' . $ath[0]['pic'] . '"/></td></tr>'; echo '<tr><td><input type="submit" class="my_button" value="Сохранить изменения"></td></tr>'; echo '</table>'; echo '</form>'; }
function getUserByUsernameOrEmailAndPassword($username, $password) { $sql_u = "SELECT * FROM signup WHERE ( email LIKE ? OR username LIKE ? ) AND `password` = ?"; $user = sqlGet($sql_u, 'sss', array($username, $username, md5($password))); return $user; }
$sortingOrder = 'price'; } } $link = mysql_connect('localhost', 'nfuogibo', 'T6iT0i0a1j') or die('Не удалось соединиться: ' . mysql_error()); mysql_select_db('nfuogibo_goods') or die('Не удалось выбрать базу данных nfuogibo_goods'); $memcache_host = 'localhost'; $memcache_port = 11211; $memcache = new Memcache(); if (!$memcache->connect($memcache_host, $memcache_port)) { die("Memcached не доступен: {$memcache_host}:{$memcache_port}"); } if ($sortingOrder == 'id') { $ath = sqlGet("SELECT * FROM goods ORDER BY id ASC;"); } else { #$ath = mysql_query("SELECT * FROM goods ORDER BY price ASC;"); $ath = sqlGet("SELECT * FROM goods ORDER BY price ASC;"); } echo '<div class = "header">'; echo '<div></div>'; echo '<table class="menu"><tr>'; echo '<td class="menu">'; echo '<a href="add_record.php">Добавить товар</a>'; echo '</td>'; echo '<td class="menu">'; echo '<form action="index.php" method="post">'; echo '<select name="order" onchange="this.form.submit();">'; echo '<option '; if ($sortingOrder == 'id') { echo 'selected '; } echo 'value="id">Сортировать по Id</option>';
function sqlRunGetId($sql, $types = "", $params = array(), $debug = false, $getData = false, $getId = true) { return sqlGet($sql, $types, $params, $debug, $getData, $getId); }
<?php global $dbi; $dbi = mysqli_connect(_DBHOST, _DBUSER, _DBPASS, _DBNAME); if (_USERNAME != '') { // check session token. $sql_s = "SELECT * FROM signup WHERE username LIKE ? AND token LIKE ?"; $user = sqlGet($sql_s, 'ss', array($_SESSION['site_user_username'], $_SESSION['site_user_token'])); // if not equal with what's in database, redirect. // if equal what's in db, carry on! //var_dump($user); if (count($user) == 0) { session_destroy(); setcookie("site_user_username", "", time() - 3600); setcookie("site_user_salt", "", time() - 3600); setcookie("site_user_token", "", time() - 3600); header('Location: /'); } //exit(0); } //exit(0);