Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title> Zadanie 6.1 </title>
- </head>
- <body>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "studenci";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if(isset($_POST['imie']) && isset($_POST['nazwisko']) && isset($_POST['grupa']))
- {
- $imie = $_POST['imie'];
- $nazwisko = $_POST['nazwisko'];
- $grupa = $_POST['grupa'];
- $sql_dod = "INSERT INTO student VALUES('','$imie','$nazwisko','$grupa')";
- $result1 = $conn->query($sql_dod);
- }
- $sql = "SELECT idstudent, imie, nazwisko, grupa FROM student";
- $result = $conn->query($sql);
- echo "<table border='1'>";
- echo '<tr>';
- echo '<td> idstudent </td>';
- echo '<td> imie </td>';
- echo '<td> nazwisko </td>';
- echo '<td> grupa </td>';
- echo '</tr>';
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- echo "<tr><td>" . $row["idstudent"]. " </td><td> " . $row["imie"]. " </td><td> " . $row["nazwisko"]. " </td><td> " .$row['grupa']. "</td></tr>";
- }
- } else {
- echo "0 results";
- }
- echo '</table>';
- $conn->close();
- ?>
- <fieldset>
- <legend> Dodaj studenta </legend>
- <form action ="form1.php" method ="POST">
- imie:<input type="text" name="imie"><br>
- nazwisko:<input type="text" name="nazwisko"><br>
- grupa:<input type="text" name="grupa"><br>
- <input type="submit" value="dodaj"><br>
- </form>
- </fieldset>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement