Pozdrav pre svega ,kreiram neki portal i sada sam naisao na problem naime kreirao sam skripte dodaj_novost.php , izmeni_novost.php i novost.php
I u bazu dodao potrebne tabele i sadrzaj kolona ,sada kada dodajem novost uopste ne ubacuje u bazu datu novost niti naslov niti text vec samo zabelezi datum objave i onoga ko objavljuje isto se desava i sa izmeni novost ,dok obrisi novost vrsi funkciju da li sam neki query pogresio ne znam moguca je velika verovatnoca ,evo i sadrzaj datih fajlova:
dodaj_novost.php
<?php
defined("access");
$uinfo = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE userid='$_SESSION[userid]'"));
$rank = $uinfo['rank'];
if($rank == "1") {
?>
<div id="omot">
<?php
if(isset($_POST['dodaj_novost'])) {
$naslov = htmlspecialchars(mysql_real_escape_string(addslashes($_POST['naslov'])));
$sadrzaj = htmlspecialchars(mysql_real_escape_string(addslashes($_POST['sadrzaj'])));
$datum = date('d.m.Y');
$sql = "INSERT into novosti (naslov,sadrzaj,datum) VALUES ('$naslov','$sadrzaj','$datum')";
$kveri = mysql_query($sql);
if(!$sql) {
$_SESSION['error'] = "Dogodila se greska";
header("location:/index.php");
die();
}
else {
$_SESSION['ok'] = "Uspesno ste dodali novost";
header("location:/index.php");
die();
}
}
?>
<h3> Dodaj novost! </h3>
<hr />
<br />
<form action="" method="POST">
<input type="text" name="naslov" required="required" placeholder="Naslov novosti..." class="djoxi_input"></input> <br /> <br />
<textarea type="text" name="sadrzaj" required="required" placeholder="Sadrzaj novosti..." class="textarea"></textarea> <br /> <br />
<input type="submit" name="dodaj_novost" class="reg_btn" value="Dodaj novost"></input>
</form>
</div><!-- OMOT KRAJ -->
<?php } else {
die("<script> alert('Nemate pristup!'); document.location.href='/'; </script>");
}?>
izmeni_novost.php
<?php
defined("access");
$nid = addslashes($_GET['novost']);
$info = mysql_fetch_array(mysql_query("SELECT * FROM novosti WHERE novost='$nid'"));
if($info['novost'] == ""){
die("<script> alert('Novost koju trazite ne postoji.'); document.location.href='/'; </script>");
}
?>
<?php
$uinfo = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE userid='$_SESSION[userid]'"));
$rank = $uinfo['rank'];
if($rank == "1") {
?>
<div id="novost_admin"> ADMIN KOMANDE:
<span style="margin-left:10px;"></span>
<a style="color:#fff; text-decoration:none;" href="/novost/<?php echo $info['novost']; ?>">Vrati se nazad!</a>
<span style="margin-left:10px;"></span>
<a style="color:#fff; text-decoration:none;" href="../obrisi/novost/<?php echo $info['novost']; ?>"><img src="/img/obrisi.png" style="width:15px;"> Obrisi</a>
</div>
<div id="omot">
<?php
if(isset($_POST['sacuvaj_izmene'])) {
$sadrzaj = htmlspecialchars(mysql_real_escape_string(addslashes($_POST['sadrzaj'])));
$sql = "UPDATE novosti SET sadrzaj='$sadrzaj' WHERE novost='$nid'";
$izmeni = mysql_query($sql);
if(!$sql) {
$_SESSION['error'] = "Dogodila se greska!";
header("location:/novost/$nid");
die();
}
else {
$_SESSION['ok'] = "Uspesno ste izmenili novost!";
header("location:/novost/$nid");
die();
}
}
?>
<div class="citaj">
<h3><?php echo $info['naslov']; ?> - IZMENA </h3> <hr /><br />
<div class="sadrzaj">
<form action="" method="POST">
<textarea type="text" name="sadrzaj" class="textarea" placeholder="Sadrzaj novosti..." required="required"><?php echo $info['sadrzaj']; ?></textarea>
<br />
<br />
<input type="submit" name="sacuvaj_izmene" class="reg_btn" value="Sacuvaj izmene"></input>
</form>
</div>
</div>
<br /> <br />
<?php } else {
die("<script> alert('Nemate pristup!.'); document.location.href='/'; </script>");
};
?>
</div><!-- OMOT KRAJ -->
novost.php
<?php
defined("access");
$nid = addslashes($_GET['novost']);
$info = mysql_fetch_array(mysql_query("SELECT * FROM novosti WHERE novost='$nid'"));
if($info['novost'] == ""){
die("<script> alert('Novost koju trazite ne postoji.'); document.location.href='/'; </script>");
}
?>
<?php
$uinfo = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE userid='$_SESSION[userid]'"));
$rank = $uinfo['rank'];
if($rank == "1") {
?>
<div id="novost_admin"> ADMIN KOMANDE:
<span style="margin-left:10px;"></span>
<a style="color:#fff; text-decoration:none;" href="../izmeni/novost/<?php echo $info['novost']; ?>"><img src="../img/izmeni.png" style="width:15px;"> Izmeni</a>
<span style="margin-left:10px;"></span>
<a style="color:#fff; text-decoration:none;" href="../obrisi/novost/<?php echo $info['novost']; ?>"><img src="../img/obrisi.png" style="width:15px;"> Obrisi</a>
</div>
<?php }; ?>
<div id="omot">
<?php
$kom = mysql_num_rows(mysql_query("SELECT komentar FROM komentari WHERE novost=$nid"));
?>
<div class="info_novost">
Trenutno citate: <span class="crvena"><?php echo $info['naslov']; ?></span> <br /><br />
Ovaj sadrzaj ima ukupno <span class="crvena"><?php echo $kom; ?></span> komentara <br /><br />
Datum objave: <span class="crvena"><?php echo $info['datum']; ?></span><br /><br />
</div>
<br /> <br />
<div class="citaj">
<h3><?php echo $info['naslov']; ?></h3> <hr /><br />
<div class="sadrzaj">
<?php echo nl2br($info['sadrzaj']); ?>
</div>
</div>
<br /> <br />
<h3> Komentari: <span class="crvena"><?php echo $kom; ?></span> </h3><hr />
<?php
if($_SESSION['userid'] == "") {
?>
<div id="nust"> Morate biti ulogovani kako bi ostavili komentar! </div>
<?php } else { ?>
<div id="nust">
<?php
if(isset($_POST['salji'])) {
$userid = $_POST['userid'];
$komentar = mysql_real_escape_string(addslashes($_POST['komentar']));
$sql = "INSERT into komentari (novost,userid,sadrzaj) VALUES ('$nid','$userid','$komentar')";
$kveri = mysql_query($sql);
if(!$sql) {
$_SESSION['error'] = "Dogodila se greska!";
header("location:/novost/$nid");;
}
else {
$_SESSION['ok'] = "Uspesno ste ostavili komentar!";
header("location:/novost/$nid");;
}
};
?>
Ostavite komentar: <br /> <br />
<form action="" method="POST">
<input type="text" hidden name="userid" value="<?php echo $_SESSION['userid']; ?>"></input> <br /> <br />
<textarea type="text" name="komentar" placeholder="Vas komentar..." class="textarea"></textarea> <br /> <br />
<input type="submit" name="salji" class="btn_kom" value="Komentarisi"></input>
</form>
</div>
<?php
$sql = "SELECT * FROM komentari WHERE novost=$nid";
$kom_kveri = mysql_query($sql);
while($red=mysql_fetch_assoc($kom_kveri)) {
$sadrzaj = $red['sadrzaj'];
$kuid = $red['userid'];
$komentarid = $red['komentar'];
$napisao = mysql_result(mysql_query("SELECT username FROM users WHERE userid=$kuid"),0);
?> <br />
<div id="komentar">
<?php echo $sadrzaj; ?> <br /> <br /><br /> <br /><br /> <br /><br /><hr />
Napisao: <a class="crvena" href="../korisnik/<?php echo $kuid; ?>"><?php echo $napisao; ?></a>
<?php if($rank == "1") { ?>
<span style="margin-left:600px;">ADMIN KOMANDE: <span style="margin-left:20px;"></span><a style="color:#fff;text-decoration:none;" href="/process/komentar/obrisi/<?php echo $komentarid; ?>"><img src="../img/obrisi.png" style="width:13px;"> Obrisi</a> </span>
<?php }; ?>
</div>
<?php }; mysql_free_result($kom_kveri); ?>
<?php }; ?>
</div><!-- OMOT KRAJ -->
Da li moze neko da se uljuci da mi pomogne da pronadjem gresku i da napomenem da mi ne salje nikakav error_log vec samo ne vrsi funkciju
|