Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "mysql.cba.pl";
- $username = "evolse";
- $password = "Bazadanych1";
- $dbname = "evolse";
- $imie = $_POST["txt_imie"];
- $nazwisko = $_POST["txt_nazwisko"];
- $wiek = $_POST["cmb_wiek"];
- $plec = $_POST["radio_plec"];
- $zainteresowania = $_POST["Zaint"];
- $zaint = implode(";",$zainteresowania);
- $zdjecie = addslashes(file_get_contents($_FILES['fileToUpload']['tmp_name']));
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "INSERT INTO tb_person (imie, nazwisko, wiek, plec, zainteresowania, zdjecie)
- VALUES ('$imie', '$nazwisko', '$wiek', '$plec', '$zaint', '$zdjecie')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- // Wyswietlanie obrazka + bazy (tabeli)
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT id, imie, nazwisko, plec, wiek, zainteresowania, zdjecie FROM tb_person";
- $result = $conn->query($sql);
- echo "<center><table border='2' width='20'><tr><th>ID</th><th>Imię</th><th>Nazwisko</th><th>Płeć</th><th>Wiek</th><th>Zainteresowania</th><th>Zdjęcie</th><th>EDIT</th><th>DELETE</tr>";
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $zmienna = $row["id"];
- echo "<tr><td>" . $row["id"]. "</td><td>" . $row["imie"]. "</td><td>" . $row["nazwisko"]. "</td><td>" . $row["plec"]. "</td><td>" . $row["wiek"]. "</td><td>" . $row["zainteresowania"]. "</td><td align='center'><a href =getimage.php?idd=$zmienna><img src='/img/zdjecie.png' height='20'></a></td><td align='center'><a href =''><img src='/img/edit.png' height='20'></a></td><td align='center'><a href =''><img src='/img/delete.png' height='20'></a></td></tr>";
- }
- echo "</table></center>";
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement