homepage Welcome to WebmasterWorld Guest from 54.234.141.47
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
online file change problem
fopen fput fclose HELP
penguinpage

10+ Year Member



 
Msg#: 198 posted 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

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



 
Msg#: 198 posted 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

10+ Year Member



 
Msg#: 198 posted 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

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



 
Msg#: 198 posted 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

10+ Year Member



 
Msg#: 198 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved