Wygląda on następująco:
Kod
<?php
session_start();
function connect_db()
{
mysql_connect("localhost", "nazwa_uzytkownika", "haslo") or die(mysql_error());
mysql_select_db("nazwa_bazy_danych") or die(mysql_error());
}
if($_SESSION['haslo']=="haslo")
{
if($_POST['news']=="NULL")
{
echo "<form action="dodajnews.php" method="post">
<input type="text" name="tytul" value="Tytuł news\'a" size="20">
<textarea name="news" cols="20" rows="20">Treść news\'a</textarea>
<input type="submit" value="Dodaj">
</form>";
}
else
{
$news = $_POST['news'];
$tytul = $_POST['tytul'];
$data = date('Y-m-d');
connect_db();
mysql_query ("SET NAMES latin2");
mysql_query("INSERT INTO `news` (`news`,`tytul`,`data`) VALUES ('".$news."','".$tytul."','".$data."') ") or die(mysql_error());
}
}
?>
session_start();
function connect_db()
{
mysql_connect("localhost", "nazwa_uzytkownika", "haslo") or die(mysql_error());
mysql_select_db("nazwa_bazy_danych") or die(mysql_error());
}
if($_SESSION['haslo']=="haslo")
{
if($_POST['news']=="NULL")
{
echo "<form action="dodajnews.php" method="post">
<input type="text" name="tytul" value="Tytuł news\'a" size="20">
<textarea name="news" cols="20" rows="20">Treść news\'a</textarea>
<input type="submit" value="Dodaj">
</form>";
}
else
{
$news = $_POST['news'];
$tytul = $_POST['tytul'];
$data = date('Y-m-d');
connect_db();
mysql_query ("SET NAMES latin2");
mysql_query("INSERT INTO `news` (`news`,`tytul`,`data`) VALUES ('".$news."','".$tytul."','".$data."') ") or die(mysql_error());
}
}
?>
Proszę o pomoc co jest źle.
Gdy wrzucam go na serwer to nic nie wyświetla.