Welcome to WebmasterWorld Guest from 23.22.220.37

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

online file change problem

fopen fput fclose HELP

     
3:11 am on May 10, 2003 (gmt 0)

New User

10+ Year Member

joined:May 10, 2003
posts:15
votes: 0


I am working on making a tool for my internet illiterate mom to update something on her website. The file is intended to update the "news" section of the website. For somereason, the variable wont echo into the second document. Can anyone please debug this code?

File: newsupdatepage.php

<html>
<head>
<title>UPDATE NEWS</title>
</head>
<body bgcolor="black" text="lime">
<style type="text/css">
.news {
background-color: #000099;
border-color: #000099;
border-style: solid;
color: #ffff00;
}
</style>
<center>
<form action="changenews00001.php" method="post">
<h1>UPDATE PAGE</h1><br>
<nobr><input name="$newnews" class="news" value="News goes here..."></nobr>
<br>
<input type="submit" value="CHANGE" class="news">
</form>
</body>
</html>

File: changenews00001.php

<?
echo "<p>Update mode.</p>";
$cnf = fopen("updates.php","w+");
$newnews = stripslashes(htmlspecialchars($newnews));
fputs($cnf,"<? ");
fputs($cnf,"\$newnews=\"$newnews\"; ");
fputs($cnf,"?>");
fclose($cnf);
include("index.php");
?>

Note: all that update.php is, is a file to store the variable "$newnews". index.php is the index page of her site (all of this is in a root dir).

all help would be greatly appreciated.

[edited by: jatar_k at 3:25 am (utc) on May 10, 2003]
[edit reason] problems with smileys [/edit]

3:30 am on May 10, 2003 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


Welcome to WebmasterWorld penguinpage,

for one this

<input name="$newnews" class="news" value="News goes here...">

should be

<input name="newnews" class="news" value="News goes here...">

and this
fputs($cnf,"\$newnews=\"$newnews\"; ");

puzzles me a bit not quite sure what that is. I could be a little daft but the syntax looks awry. I was going to post it properly then got confused as to what you were trying to do. What exactly are you trying to write there?

8:48 pm on May 10, 2003 (gmt 0)

New User

10+ Year Member

joined:May 10, 2003
posts:15
votes: 0

fputs($cnf,"\$newnews=\"$newnews\"; "[smilestopper]);

this is supposed to use the new news value from the form, and write it into a php file. the resultitng php file would look like this

<? $newnews="";?>

with the news from the form between the quotes

1:05 am on May 14, 2003 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


why not just write the content of the var to the file and then include it?

fputs($cnf,$newnews);

3:27 am on May 14, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 9, 2003
posts:28
votes: 0


If you wanted the contents of $newnews available as a variable in some other script, instead of includ()ing it you could maybe do this:

<? $newnews=join('', file('./updates.php'));?>

in whichever script you wanted to use $newnews. It's horribly inefficient, but nice and easy.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members