Cześć, mam problem z CRUD wcześniej działał a teraz nie chcę :D nie wiem gdzie jest błąd pomożecie mi go znaleźć mianowicie mam zaimplementowany system edycji czyli gotową rubrykę z informacjami można edytować i właśnie to nie działa, nie chcę zmienić na nowe informacje. :)
index.php
<?php include('server.php');
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$edit_state = true;
$view_state = true;
$rec = mysqli_query($db, "SELECT * FROM info WHERE id=$id");
$record = mysqli_fetch_array($rec);
$name = $record['name'];
$plec = $record['plec'];
$poszukiwany = $record['poszukiwany'];
$karany = $record['karany'];
$opis = $record['opis'];
$policjant = $record['policjant'];
$data = $record['data'];
$id = $record['id'];
}
?>
<?php
// Initialize the session
session_start();
// If session variable is not set it will redirect to login page
if(!isset($_SESSION['username']) || empty($_SESSION['username'])){
header("location: login.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8">
<title>Baza Danych Los Santos</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="author" content="Vinchit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<link rel="stylesheet" type="text/css" href="view.css">
<meta name="author" content="Vinchit">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<?php if (isset($_SESSION['msg'])): ?>
<div class="msg">
<?php
echo $_SESSION['msg'];
unset($_SESSION['msg']);
?>
</div>
<?php endif; ?>
<header>
<h1 class="logo">Los Santos Police Department</h1>
</header>
<div id="pasek" class="przycisk">
<a href="dodawanie.php" class="btn btn-success "><span class="glyphicon glyphicon-plus"></span>Dodaj obywatela</a>
<a href="taryfikator.html" class="btn btn-info "><span class="glyphicon glyphicon-euro"></span>Taryfikator</a>
<a href="logout.php" class="btn btn-danger "><span class="glyphicon glyphicon-log-out"></span> Wyloguj się</a>
</div>
<table>
<thead>
<tr class="tabelki">
<th>Imię i Nazwisko</th>
<th>Plec</th>
<th>Poszukiwany</th>
<th>Policjant</th>
<th>Data</th>
<th colspan="3">Więcej/Edytuj/Usuń</th>
</tr>
</thead>
<tbody>
<?php while ($row = mysqli_fetch_array($results)) { ?>
<tr class="tabelki">
<td><?php echo $row['name'] ?></td>
<td><?php echo $row['plec'] ?></td>
<td><?php echo $row['poszukiwany'] ?></td>
<td><?php echo $row['policjant'] ?></td>
<td><?php echo $row['data'] ?></td>
<td>
<a class="view_btn" href="view.php?view=<?php echo $row['id']; ?>">Więcej</a>
</td>
<td>
<a class="edit_btn" href="dodawanie.php?edit=<?php echo $row['id']; ?>">Edytuj</a>
</td>
<td>
<a class="del_btn" href="server.php?del=<?php echo $row['id']; ?>">Usuń</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div>
<script src="assets/js/jquery-1.10.2.js"></script> <script src="assets/js/bootstrap.js"></script> <script src="assets/js/dataTables/jquery.dataTables.js"></script> <script src="assets/js/dataTables/dataTables.bootstrap.js"></script> <script src="assets/js/custom.js"></script>
</div>
</body>
</html>
dodawanie.php (prawdopodobnie tu jest błąd ale nie potrafię go znaleźć)
<?php
// Initialize the session
session_start();
// If session variable is not set it will redirect to login page
if(!isset($_SESSION['username']) || empty($_SESSION['username'])){
header("location: login.php");
exit;
}
?>
<?php include('server.php');
// fetch the record to be Update
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$edit_state = true;
$rec = mysqli_query($db, "SELECT * FROM info WHERE id=$id");
$record = mysqli_fetch_array($rec);
$name = $record['name'];
$plec = $record['plec'];
$poszukiwany = $record['poszukiwany'];
$karany = $record['karany'];
$opis = $record['opis'];
$policjant = $record['policjant'];
$data = $record['data'];
$id = $record['id'];
}
?>
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<title>Dodawanie obywatela</title>
<meta name="author" content="Vinchit">
<link rel="stylesheet" type="text/css" href="view.css">
<meta name="author" content="Vinchit">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<img class="logopolice" src="">
<div class="login">
<form method="post" action="server.php">
<div>
<label class="kat">Imię i Nazwisko:</label>
<input class="wkat" type="text" name="name" value="<?php echo $name; ?>" />
</div>
<div>
<label class="kat">Plec:</label>
<input class="wkat" type="text" name="plec" value="<?php echo $plec; ?>" />
</div>
<div>
<label class="kat">Poszukiwany:</label>
<input class="wkat" type="text" name="poszukiwany" value="<?php echo $poszukiwany; ?>" />
</div>
<div>
<label class="kat">Karany:</label>
<input class="wkat" type="text" name="karany" value="<?php echo $karany; ?>" />
</div>
<div>
<label class="kat">Opis:</label>
</div>
<div>
<textarea name="opis" type="text" rows="4" cols="50" style="height: 120px; width: 600px; background: #26283ca6; color: white;">
<?php echo $opis; ?>
</textarea>
</div>
<div>
<label class="kat">Policjant:</label>
<input class="wkat" type="text" name="policjant" value="<?php echo $policjant; ?>" />
</div>
<div>
<label class="kat">Data:</label>
<input class="wkat" type="text" name="data" name="data" value="<?php echo $data; ?>" />
</div>
<div class="pkat">
<?php if ($edit_state == false): ?>
<button type="submit" name="save" class="btn btn-success">Dodaj obywatela</button>
<?php else: ?>
<button type="submit" name="update" class="btn btn-success">Zmień</button>
<?php endif ?>
</div>
</form>
</div>
</body>
</html>
Szukałem błędu dobre 20 minut i nie mogę go zlokalizować (pewnie ze zmęczenia)