Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta content="text/html; charset=utf-8" http-equiv="content-type">
- </head>
- <body>
- <?php
- session_start();
- echo " <form method='post' action='index.php'>";
- echo "<select name='kod_ucznia'>";
- $conn=mysqli_connect('localhost','root','','dziennik');
- $zap=mysqli_query($conn,"select * from uczen");
- while( $wynik=mysqli_fetch_array($zap))
- {
- if ($_SESSION['aaa']==$wynik['ID'])
- {
- echo "<option value='".$wynik['ID']."' selected> ".$wynik['nazwisko']."</option>\n";
- }
- else
- echo "<option value='".$wynik['ID']."'> ".$wynik['nazwisko']."</option>\n";
- }
- echo "</select>";
- ?>
- <p> <input type="submit" name="submit" VALUE="dodaj" > </p>
- <p> <input type="submit" name="submit" VALUE="usun" > </p>
- <p> <input type="submit" name="submit" VALUE="edytuj" > </p>
- <?php
- if (isset($_POST['submit'])){
- if (($_POST['submit'])=='usun')
- {
- $uczen=$_POST['kod_ucznia'];
- $zap1=mysqli_query($conn,"delete from uczen where ID='".$uczen."'");
- header("refresh:0");
- }
- }
- if (isset($_POST['submit'])){
- if (($_POST['submit'])=='dodaj')
- {
- echo "<p> <input type='text' name='imie'> </p>";
- echo "<p> <input type='text' name='nazwisko'> </p>";
- echo "<p> <input type='text' name='klasa'> </p>";
- echo "<p> <input type='submit' name='zapisywanie' VALUE='zapisz' > </p> ";
- }
- }
- //var_dump ($_POST);
- if (isset($_POST['zapisywanie'])){
- if (($_POST['zapisywanie'])=='zapisz')
- {
- $imie=$_POST['imie'];
- $nazwisko=$_POST['nazwisko'];
- $klasa=$_POST['klasa'];
- mysqli_query($conn,"insert into uczen values (default, '$imie', '$nazwisko', $klasa);");
- header("refresh:0");
- }
- echo "<br><br><br>";
- }
- if (isset($_POST['submit'])){
- if (($_POST['submit'])=='edytuj')
- {
- $uczen=$_POST['kod_ucznia'];
- $_SESSION['aaa']=$uczen;
- echo $uczen."<br>";
- echo $_SESSION['aaa']."<br>";
- $zap1=mysqli_query($conn,"select * from uczen where ID='".$uczen."'");
- $rekord=mysqli_fetch_array($zap1);
- $imie=$rekord['imie'];
- $nazwisko=$rekord['nazwisko'];
- $klasa=$rekord['ID_KLASY'];
- echo "<p> imie <input type='text' name='imie' value='".$imie."'> </p>" ;
- echo "<p> nazwisko <input type='text' name='nazwisko' value='".$nazwisko."'> </p>";
- echo "<p> klasa <input type='text' name='klasa'value='".$klasa."'> </p>";
- echo "<p> <input type='submit' name='edytowanie' VALUE='zapisz' > </p> ";
- }
- }
- //var_dump ($_POST);
- if (isset($_POST['edytowanie'])){
- if (($_POST['edytowanie'])=='zapisz')
- {
- $imie=$_POST['imie'];
- $nazwisko=$_POST['nazwisko'];
- $klasa=$_POST['klasa'];
- $uczen=$_SESSION['aaa'];
- echo $uczen."<br>";
- mysqli_query($conn,"update uczen SET imie='".$imie."', nazwisko='".$nazwisko."', ID_KLASY='".$klasa."' where ID=$uczen;");
- header("refresh:0");
- }
- echo "<br><br><br>";
- }
- ?>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement