Niżej wklejam napisany przeze mnie kod
<?php include '../db.php'; $mysqli->set_charset("utf8"); function createForm($p_imie = '', $p_nazwisko = '', $p_login = '', $p_haslo = '', $p_telefon = '', $p_status = '', $error = '', $id = '') { ?> <!DOCTYPE html> <html> <head> <title><?php if ($id != '') { } else { } ?></title> <link rel="Stylesheet" type="text/css" href="../css/style.css" /> <link href='http://fonts.googleapis.com/css?family=Josefin+Sans&subset=latin,latin-ext' rel='stylesheet' type='text/css' /> <meta charset="UTF-8" /> </head> <body> <header> <div class="header"> <div id="header_img"> <img src="../image/logov2.png" alt="Logo" /> </div> </div> <div class="header_menu"> <ul> <li><a href="../logout.php">Wyloguj</a></li> </ul> </div> </header> <br /> <section> <article class="article_1"> <div id="menu_img"> <img src="../image/image_cms_1.png" alt="Logo"/> <br /><br /><br /><br /> <ul> <li><a href="../pracownik/pracownik.php">Pracownik</a></li> <ul> <li><a href="edytuj.php">Dodaj pracownika</a></li> </ul> <li><a href="../pojazd/pojazd.php">Pojazd</a></li> <li><a href="../towar/towar.php">Towar</a></li> <li><a href="../statystyki.php">Statystyki</a></li> </ul> </div> </article> <article class="article_2"> <h2><?php if ($id != '') { } else { } ?></h2> <?php if ($error != '') { } ?> <form action="" method="post"> <div class="for"> <?php if ($id != '') { ?> <br /> <?php } ?> <br /> <p><label>Nazwisko: </label><input type="text" name="nazwisko" value="<?php echo $p_nazwisko ?>"/></p><br /> <p><label>Login: </label><input type="text" name="login" value="<?php echo $p_login ?>" /></p><br /> <p><label>Hasło: </label><input type="password" name="password" value="<?php echo $p_haslo ?>" /></p><br /> <p><label>Telefon: </label><input type="tel" name="tel" value="<?php echo $p_telefon ?>" /></p><br /> <!--<p><label>Status: </label><input type="text" name="status" value="<?php echo $p_status ?>" /></p><br />--> <p><label>Status: </label><select name="status"><option><?php echo $p_status ?></option></select></p><br /> <br /> <input type="submit" name="submit" value="Dodaj" /> </div> </form> </article> </section> </body> <footer> <div class="footer"> <br /> <p>Copyright Š 2014 Autorzy: Tomasz Łapiński, Joanna Cieślik, Emil Jakonczuk, Adam Cieszewski, Artur Parafiniuk</p> </div> </footer> </html> <?php } $id = $_POST['id']; if ($_imie == '' || $_nazwisko == '' || $_login == '' || $_haslo == '' || $_tel == '' || $_status == '') { $error = "Wypełnij wszystkie pola"; createForm($_imie, $_nazwisko, $_login, $_haslo, $_tel, $_status, $error); } else { if ($stmt = $mysqli->prepare("UPDATE pracownik SET imie=?, nazwisko=?, login=?, haslo=?, telefon=?, pracownik_status_id=? WHERE id=?")) { $stmt->bind_param("sssssii", $_imie, $_nazwisko, $_login, $_haslo, $_tel, $_status, $id); $stmt->execute(); $stmt->close(); } else { } } } } else { $id = $_GET['id']; if ($stmt = $mysqli->prepare("SELECT * FROM pracownik WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $imie, $nazwisko, $login, $haslo, $tel, $status); $stmt->fetch(); createForm($imie, $nazwisko, $login, $haslo, $tel, $status, NULL, $id); $stmt->close(); } else { } } else { } } } else { if ($_imie == '' || $_nazwisko == '' || $_login == '' || $_haslo == '' || $_tel == '' || $_status == '') { $error = "Wypełnij wszystkie pola"; createForm($_imie, $_nazwisko, $_login, $_haslo, $_tel, $_status, $error); } else { if ($stmt = $mysqli->prepare("INSERT pracownik (imie,nazwisko,login,haslo,telefon,pracownik_status_id) VALUES (?,?,?,?,?,?)")) { $stmt->bind_param("sssssi", $_imie, $_nazwisko, $_login, $_haslo, $_tel, $_status); $stmt->execute(); $stmt->close(); } else { } } } else { createForm(); } } $mysqli->close(); ?>