/    Sign up×
Community /Pin to ProfileBookmark

News edit script, got som problems

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/”;
?>
[/code]

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>
<?
}
?>
[/code]

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

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@kattenauthorDec 22.2005 — Anyone got a answere :S i realy need to know
×

Success!

Help @katten spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...