Laboratorium -Sprawozdanie nr 2.docx

(317 KB) Pobierz

 

 

http://flooder.pl/prawa/glowna.php

test : test

test1 : test

test2 : test

 

 

 

 

 

 

 

 

<?php ob_start(); ?>

<html>

<head>                                                                                                         

<meta http-equiv="Content-Type" content="text/html;charset=iso-8852-2" >

</head>

<body><style type="text/css">

body {background-image: url(bg.png); background-repeat: repeat-x; background-color: #b0c1dd }

input {list-style-type: none; width: 300px }

h1 {font-size: 25px; font-family: Arial, Helvetica, Verdana, sans-serif; text-align: center }

.ksiazka_img {width: 75% }

.ksiazka {position: absolute; margin-left: -30px }

.tytul {font-size: 33px; text-align:center; font-family: Arial, Helvetica, Verdana, sans-serif }

.tresc {font-size: 17px; text-align:center; font-family: Arial, Helvetica, Verdana, sans-serif }

.alert {font-size: 15px; text-align:center; font-family: Arial, Helvetica, Verdana, sans-serif; color:red }

.formularz {font-size:15px; font-family: Arial, Helvetica, Verdana, sans-serif }

.table0 {width: 500px; border:1px; background-color: #6c7c98; margin-left:auto; margin-right:auto; border-top-style: solid; border-bottom-style: solid; border-right-style: solid; border-left-style: solid}

.table1 {width: 150px}

.table2 {width: 200px}

.table3 {width: 700px; border-collapse: collapse; border:0px; margin-left:auto; margin-right:auto; border-top-style: solid; border-bottom-style: solid; border-right-style: solid; border-left-style: solid}

.table4 {width: 100px; border-collapse: collapse; background-color: #6c7c98; border:1px; margin-left:auto; margin-right:auto; border-top-style: solid; border-bottom-style: solid; border-right-style: solid; border-left-style: solid}

.table5 {width: 600px; border-collapse: collapsebackground-color: #a7b4c1; border:1px; margin-left:auto; margin-right:auto; border-top-style: solid; border-bottom-style: solid; border-right-style: solid; border-left-style: solid}

.table6 {border: 1px;}

.table7 {width: 25%}

.links {width: 500px; margin-left: auto; margin-right: auto }

A:link {color: #ffffff }

A:visited {color: #000000 }

A:active {color: #4e5052 }

A:hover {color: #5688bb }

.links A:link {font-size: 17px; font: bold; color: #5688bb  }

.links A:visited {font-size: 17px; color: #000000 }

.links A:active {font-size: 17px; color: #5688bb }

.links A:hover {font-size: 17px; color: #4e5052 }

</style>

 

 

<?php

ob_start();

 

mysql_connect('db388336833.db.1and1.com','dbo388336833','zaq12wsX');    

mysql_select_db('db388336833');             

 

echo "<a href=\"opcja2.php?action=add_new_item\" >Dodaj nowy wpis</a> | <a href=\"glowne.php\">Powrót do poprzedniego MENU</a>";

 

$action=$_GET["action"];

$query = mysql_query("SELECT * FROM tab1") or die('B³¹d zapytania');

 

echo "<p class=\"tresc\">Lista wpisów w systemie:</p>";

if(mysql_num_rows($query) > 0) {

    /* je¿eli wynik jest pozytywny, to wyœwietlamy dane */

    echo "<table class=\"table0\">";

    while($result = mysql_fetch_assoc($query)) {

        echo "<tr>";

        echo "<td class=\"table7\"><label class=\"formularz\">".$result['p1']."</label></td>";

        echo "<td class=\"table7\"><label class=\"formularz\">".$result['p2']."</label></td>";

        echo "<td class=\"table7\"><label class=\"formularz\">".$result['p3']."</label></td>";

        echo "<td class=\"table7\"><a href=\"opcja2.php?action=delete_item&id={$result['id']}\">Usu&#324</a></td>";

        echo "</tr>";

    }

    echo "</table>";

}

 

if ($action=="delete_item")

{

$id=$_GET["id"];

$query = "DELETE FROM tab1 WHERE id='$id'";

mysql_query($query);

header("location:opcja2.php");

}

 

if ($action=="add_new_item"){

echo "

<p class=\"tresc\">Wype&#322nij poni&#380sze pola:</p>

<form method=\"post\" action=\"opcja2.php?action=adding_item\">

<table class=\"table0\">

<tr>

<td class=\"table1\"><label class=\"formularz\">Nazwa: </label></td>

<td class=\"table2\"><input type=\"text\" name=\"p1\"></td>

</tr>

<tr>

<td class=\"table1\"><label class=\"formularz\">Producent: </label></td>

<td class=\"table2\"><input type=\"text\" name=\"p2\"></td>

</tr>

<tr>

<td class=\"table1\"><label class=\"formularz\">Lokalizacja: </label></td>

<td class=\"table2\"><input type=\"text\" name=\"p3\"></td>

</tr>

<tr>

<td class=\"table1\"></td>

<td class=\"table2\"><input type=\"submit\" value=\"Dodaj\" style=\"width: 150px;\"><input type=\"reset\" name=\"Wyczy&#347c\" style=\"width: 150px;\"></td>

</tr>

</table>

</form>";

}

 

if ($action=="adding_item")

{

  $p1=$_POST["p1"];

  $p2=$_POST["p2"];

  $p3=$_POST["p3"];

   if (empty($p1)==TRUE) /* czy pole z nickiem jest puste */

  {

                echo "<p class=\"alert\">Uzupe&#322nij pole z nazw&#261!</p>";

                $warning=1;

  }

  if (empty($p2)==TRUE) /* czy pole z tekstem jest puste */

  {

                echo "<p class=\"alert\">Uzupe&#322nij pole z producentem!</p>";

                $warning=1;

  }

   if (empty($p3)==TRUE) /* czy pole z nickiem jest puste */

  {

                echo "<p class=\"alert\">Uzupe&#322nij pole z lokalizacj&#261!</p>";

                $warning=1;

  }

 

  if ($warning!=1) /* czy wyst¹pi³y jakieœ b³êdy */

  { 

  $add = @mysql_query("INSERT INTO tab1 SET p1='$p1', p2='$p2', p3='$p3'");

...

Zgłoś jeśli naruszono regulamin