function checkUser() { $nameUser = $_COOKIE['log']; $result = mysqli_query(connect(), "SELECT * FROM users WHERE name = '{$nameUser}'"); while ($rslt = mysqli_fetch_row($result)) { $id = $rslt[0]; } $result1 = mysqli_query(connect(), "SELECT * FROM companies WHERE userID = '{$id}'"); $nameCompany = ""; while ($rslt1 = mysqli_fetch_row($result1)) { $nameCompany = $rslt1[1]; $a = $rslt1[2]; $p = $rslt1[3]; } close_bd(); if ($nameCompany == null) { echo "У вас нет компании"; controller_insertCompany(); } else { $id = $_COOKIE['companyID']; echo "<form action=http://localhost/companies/index.php?page=companies&action=edit&id={$id} method=post> Ваша компания: {$nameCompany}<br>\n\t\t<input class=button type=submit value=Редактировать name = but/></form>"; //echo "<form action=http://localhost/companies/index.php?page=products&action=edit&id=$id method=post/></form>"; echo "<form method=post action=index.php?page=companies&action=delete&id={$id}><br><input class=button type=submit value=\"Удалить\" name = but/></form>"; controller_products_index(); } close_bd(); }
// добавить продукт------------------------------------------------------------------------------------------------------- // нажимаем f5 - запрос идет повторно - получается один продукт добавляется дважды // защита: post-redirect-get----------------------------------------------------------------------------------------------- */ switch (@$_GET['page']) { case null: $h1_header = "Главная страница"; main_controller(); break; case "companies": $h1_header = "Компании"; controller_companies_index(); break; case "products": $h1_header = "Products"; controller_products_index(); break; case "insertCompany": ///////////////////// $h1_header = "insertCompany"; set_cookie("insertCompany", "1"); //setcookie("insertCompany", 1, time() + 3600*24*30*12, "/"); controller_insertCompany(); break; case "insertProduct": ///////////////////// $h1_header = "insertProduct"; set_cookie("insertProduct", "1"); //setcookie("insertProduct", 1, time() + 3600*24*30*12, "/"); controller_insertProduct(); break;