Yeap well as the title says i have made a news edit script for my webpage so people so gamemaster of my game can edit the news if somthing good or funnie has happend.so i will post the code and see if you exeperts can find the bug because i can’t… ?
Config.php
[code=php]
<?php
// config.php
$forum = “no”;
$logo = “yes”;
$logo_name = “tibia.gif”;
$logo_text = “www.tibia.now”;
$world_name = “Tibia.now”;
$server_amount = “2”;
$main_server_name = “Secura”;
$secondary_server_name = “Inferna”;
$number_of_players_shown_in_stats = “20”;
$title = “www.tibia.now – Powerd by katten aac 1.0.2″;
/* Please rember that the logo should be width=”700″ and heigt=”120” for it to fit in. and also don’t forgett the ending in the file ither */
$town_x_1 = “117”;
$town_x_2 = “”;
$town_x_3 = “”;
$town_x_4 = “”;
$town_x_5 = “”;
$town_name_1 = “hell”;
$town_name_2 = “”;
$town_name_3 = “”;
$town_name_4 = “”;
$town_name_5 = “”;
$news = “C:\xampplite\htdocs\katten\includes\news//”;
$main_server_house = “C:\xampplite\htdocs\katten\main server\data\houses.xml//”;
$login_server = “C:\xampplite\htdocs\Katten\login server/”;
$include_dir = “C:\xampplite\htdocs\katten\includes//”;
$folderdata = “C:\xampplite\htdocs\Katten\main server\data//”;
$folderplayer = “C:\xampplite\htdocs\Katten\main server\data\players/”;
$folderaccounts = “C:\xampplite\htdocs\Katten\main server\data\accounts/”;
$folder_secondary_data = “C:\xampplite\htdocs\Katten\secondary server\data//”;
$folder_secondary_players = “C:\xampplite\htdocs\Katten\secondary server\data\players/”;
$folder_secondary_accounts = “C:\xampplite\htdocs\Katten\secondary server\data\accounts/”;
$monster_folder = “C:\xampplite\htdocs\Katten\main server\data\monster/”;
?>
News edit.php
[code=php]
<?php
################################
####### INCLUDES #######
################################
include(“../includes/config.php”);
include(“../includes/news/index_news_postcache.php”);
include(“../includes/news/index_news.php”);
###########################
####### NEWS #######
###########################
$error = 0;
$news_name = “index_news”;
$makedate = date(“Y-m-d H:i:s”);
$news_title = trim($_POST[“news_title”]);
$news_txt = trim($_POST[“news_txt”]);
$news_by = trim($_POST[“news_by”]);
if (isset($news_title) && isset($news_txt) && $news_title != “” && $news_txt != “”) {
$error = 0;
###################
## error section ##
###################
if ($news_title == “” )
{
echo “<font color=’red’>You can’t post news with out a title</font>”;
$error = 1;
}
else
if ($news_txt == “”)
{
echo “<font color=’red’>You can’t post news with out any contents</font>”;
$error = 1;
} else if ($error == 0) {
#######################
### write file part ###
#######################
if (file_exists($news . $news_name . “.php”)) {
$file = fopen($news . $news_name . “.php”, “w”);
$output = ”
<table>
<tr>
<td>$news_title</td>
</tr>
<tr>
<td>$news_txt</td>
</tr>
<tr>
<td>$news_by</td>
</tr>
</table>
“;
fwrite($file, $output);
$created = true;
session_unset();
}
}
?>
<font color=”black” size=”4″>Your news was successfully created.<br><br></font>
<?
}
if ($created != true) {
?>
<font color=”000000″ size=”3″>Created your own web-site news here!</font>
<form action=”<?=$PHP_SELF?>” method=”POST”>
<table>
<tr>
<td>News title: </td><td><input name=”news_txt” type=”text” value=”” class=”textfield”>
</tr>
<tr>
<td>News text: </td><td><input name=”news_txt” type=”text” value=”” class=”textfield”>
</tr>
<tr>
<td>News by: </td><td><input name=”news_by” type=”text” value=”” class=”textfield”>
</tr>
</table>
<br>
<input type=”Submit” value=”Create Account”>
<input type=”Reset” value=”Clear Form”>
</form>
<?
}
?>
Please explain what i did wrong and why it dosen’t work because i’m only 14 and want to learn more about php ?
Yours katten