Hej,
Jeg har problemer med at få denne kode til at opdatere en nyhed jeg vælger i "editnews.php" jeg kan godt vælge en nyhed i den fil der ..
Når jeg så kommer ind på filen "edit_news.php?id=X" kan jeg se den valgte nyhed men når jeg så kommer ind og trykker update så er felterne ikke længere fyldt og den siger "The Fields Are Not Full"
Hele systemet:
editnews.php :
<?php
session_start();
?>
<style type="text/css">
<!--
body,td,th {
color: #000000;
}
body {
background-color: #BE0000;
}
a {
font-weight: bold;
}
a:link {
text-decoration: none;
color: #000000;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #000000;
}
a:active {
text-decoration: none;
color: #000000;
}
-->
</style><title>[Team-SMG]</title><body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">
<div align="center">
<p align="center">
<?php
if(isset($_SESSION['logget_ind'])){
include ("sql.php");
$get_user = mysql_query("SELECT * FROM users WHERE brugernavn = '$brugernavn'");
$row = mysql_fetch_array($get_user);
if($row['status'] == "Clan-Leader")
{
?>
<b>Edit News </b>
<p align="center"><?php
$pr_side = 8;
$antal = mysql_result(mysql_query("SELECT COUNT(*) FROM news"),0) or die(mysql_error());
$vis_fra = (isset($_GET["visfra"]) && is_numeric($_GET["visfra"]) && $_GET["visfra"] < $antal) ? $_GET["visfra"] : 0;
$query = mysql_query ("SELECT * FROM news ORDER BY id DESC limit $vis_fra, $pr_side") or die(mysql_error());
while($row = mysql_fetch_array($query)){
echo "<table border='0'><tr valign='top'><td><b><a href='edit_news.php?id=".$row['id']."' target='teamsmg'>".$row['overskrift']."</a></tr></td></b></table>";
echo "<img src='../images/linje.bmp'><br>";
}
if ($vis_fra > 0) {
$back= $vis_fra - $pr_side;
echo "<a href='$_SERVER[PHP_SELF]?visfra=$back'>Previous</a> ";
}
$page = 1;
for ($start = 0; $antal > $start; $start = $start + $pr_side) {
if($vis_fra != $page * $pr_side - $pr_side) {
echo "<a href='$_SERVER[PHP_SELF]?visfra=$start'>$page</a> ";
} else {
echo $page." ";
}
$page++;
}
if ($vis_fra < $antal - $pr_side) {
$next = $vis_fra + $pr_side;
echo " <a href='$_SERVER[PHP_SELF]?visfra=$next'>Next</a>";
}
?>
<br>
<?
}elseif($row['status'] == "Clan-Member"){
echo "<b>Error</b>
<br><br>You are logget on at the status Clan-Member :s";
}elseif($row['status'] == "User")
{
echo "<b>Error</b>
<br><br>You are logget on at the status User :s";
}
}
else
{
echo "<b>Error</b>
<br><br> You are not logged on :s";
}
?>
</div>
</div>
</div>
</body>
</html>
edit_news.php :
<?php
session_start();
?>
<style type="text/css">
<!--
body,td,th {
color: #000000;
}
body {
background-color: #BE0000;
}
a {
font-weight: bold;
}
a:link {
text-decoration: none;
color: #000000;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #000000;
}
a:active {
text-decoration: none;
color: #000000;
}
-->
</style><title>[Team-SMG]</title><body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">
<div align="center">
<p align="center">
<?php
if(isset($_SESSION['logget_ind'])){
include ("sql.php");
$get_user = mysql_query("SELECT * FROM users WHERE brugernavn = '$brugernavn'");
$row = mysql_fetch_array($get_user);
if($row['status'] == "Clan-Leader")
{
?>
<b>Edit News </b>
<p align="center"><?php
$get_id = mysql_query("SELECT * FROM news WHERE id = '".$_GET['id']."'");
$row0 = mysql_fetch_array($get_id);
$id = $row0['id'];
$get_news = mysql_query("SELECT * FROM news WHERE id = '$id'");
$row = mysql_fetch_array($get_news);
$tekst = $row['tekst'];
$overskrift = $row['overskrift'];
$id = $row['id'];
$tek = $_POST['tekst'];
$sub = $_POST['head'];
if(isset($_GET['tjek'])){
if(empty($tek)){
echo "The fields are not full !";
}elseif(isset($sub)){
echo "The fields are not full !";
}else{
mysql_query("UPDATE news SET tekst='".$tek."', overskrift='".$sub."' WHERE id='".$id."'");
}
}
}
?>
<form method="post" action="edit_news.php?tjek">
<div align="center">Subjekt:<br>
<input type="text" name="head" value="<?php echo ($overskrift); ?>" style="background-color:#99CCCC">
<br>
News text:<br>
<textarea name="tekst" cols="30" rows="6" style="background-color:#99CCCC"><?php echo ($tekst); ?></textarea>
<br>
<input type="submit" value="Update" style="background-color:#99CCCC">
</div>
</form>
<br>
<?
}elseif($row['status'] == "Clan-Member"){
echo "<b>Error</b>
<br><br>You are logget on at the status Clan-Member :s";
}elseif($row['status'] == "User")
{
echo "<b>Error</b>
<br><br>You are logget on at the status User :s";
}
else
{
echo "<b>Error</b>
<br><br> You are not logged on :s";
}
?>
</div>
</div>
</div>
</body>
</html>
Undskyld hvis koden er rodet
Håber i kan hjælpe mig