homepage Welcome to WebmasterWorld Guest from 23.22.212.158
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library : Charter : Moderators: coopster & eelixduppy & jatar k

PHP Server Side Scripting Forum

    
online file change problem
fopen fput fclose HELP
penguinpage




msg:1283308
 3:11 am on May 10, 2003 (gmt 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]

 

jatar_k




msg:1283309
 3:30 am on May 10, 2003 (gmt 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?

penguinpage




msg:1283310
 8:48 pm on May 10, 2003 (gmt 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

jatar_k




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

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

fputs($cnf,$newnews);

mischief




msg:1283312
 3:27 am on May 14, 2003 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved