Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 14th, 2003, 10:38 PM
benos benos is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 233 benos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Article Dicussion: Creating a News System with PHP

If you have any questions or comments about this article please post them here.

This forum post relates to this article

Reply With Quote
  #2  
Old April 17th, 2003, 07:47 PM
zao zao is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 1 zao User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Notice: Undefined index: submit in c:\inetpub\wwwroot\news.php on line 3

That's the error that I get when running the addnews.php part of this.

Reply With Quote
  #3  
Old April 18th, 2003, 09:14 PM
benos benos is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 233 benos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Code for news.php

PHP Code:
<?
echo "<H1><u>Current News</u></H1>\n";
$data file('news.txt');
$data array_reverse($data);
foreach(
$data as $element) {
    
$element trim($element);
    
$pieces explode("|"$element);
    echo 
$pieces[2] . "<BR>" "<b>Posted by " $pieces[1] . " on " $pieces[0] . "</b><BR><BR>";
}
echo 
"<HR>\n";
echo 
"<H1><u>Add News</u></H1>\n";
if(
$HTTP_POST_VARS['submit']) {
    if(
$HTTP_POST_VARS['password'] == 'pass') {
        if(!
$HTTP_POST_VARS['name']) {
            echo 
"You must enter a name";
            exit;
        }
        if(!
$HTTP_POST_VARS['news']) {
            echo 
"You must enter some news";
            exit;
        }
        if(
strstr($HTTP_POST_VARS['name'],"|")) {
            echo 
"Name cannot contain the pipe symbol - |";
            exit;
        }
        if(
strstr($HTTP_POST_VARS['news'],"|")) {
            echo 
"News cannot contain the pipe symbol - |";
            exit;
        }
        
$fp fopen('news.txt','a');
        if(!
$fp) {
            echo 
"Error opening file!";
            exit;
        }
        
$line date("m.d.y") . "|" $HTTP_POST_VARS['name'];
        
$line .= "|" $HTTP_POST_VARS['news'];
        
$line str_replace("\r\n","<BR>",$line);
        
$line .= "\r\n";
        
fwrite($fp$line);
        if(!
fclose($fp)) {
            echo 
"Error closing file!";
            exit;
        }
        echo 
"<b>News added!</b>\n";    
    } else {
        echo 
"Bad Password";
    }
}
?>
<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry">
Your name:<BR>
<INPUT TYPE="text" SIZE="30" NAME="name"><BR>
The News:<BR>
<TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR><BR>
News Password:<BR>
<INPUT TYPE="password" SIZE="30" NAME="password"><BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Post it!"><BR>
</FORM>


This code worked for me.

The Error you recieved

Quote:
Notice: Undefined index: submit in c:\inetpub\wwwroot\news.php on line 3


Could have occured when you first opened the page. To fix this you may simply replace,

PHP Code:
if($HTTP_POST_VARS['submit']) { 


with

PHP Code:
if(isset($HTTP_POST_VARS['submit'])) { 


I hope this helped

Reply With Quote
  #4  
Old August 4th, 2003, 12:35 PM
pakcik_kantin pakcik_kantin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Kantin
Posts: 18 pakcik_kantin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Keep on addding when refresh

Hallo, anybody can help me..
when i refresh my browser, it keep posting new news...
How to prevent this

Reply With Quote
  #5  
Old August 18th, 2003, 06:52 PM
Firestorm03 Firestorm03 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 Firestorm03 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am confused. You don't say what file the php scripts go in, help me!

Reply With Quote
  #6  
Old December 14th, 2003, 09:03 PM
spacious spacious is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Michigan, USA
Posts: 3 spacious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Warning: fopen(news.txt): failed to open stream: Permission denied in D:\Websites\URL on line 116


thats what i get,

line 116 is

PHP Code:
 $fp fopen('news.txt','a'); 

Reply With Quote
  #7  
Old December 15th, 2003, 03:08 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Spacious,

Do you have write permissions set on that folder? Make sure you do, otherwise, you would be receiving that error.

Also, what's the line above 116? Can you post a block from that area.

Thanks.

Reply With Quote
  #8  
Old December 15th, 2003, 09:29 PM
spacious spacious is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Michigan, USA
Posts: 3 spacious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Code:
if(!$HTTP_POST_VARS['news']) {
            echo 
"You must enter some news";
            exit;
        }
        if(
strstr($HTTP_POST_VARS['name'],"|")) {
            echo 
"Name cannot contain the pipe symbol - |";
            exit;
        }
        if(
strstr($HTTP_POST_VARS['news'],"|")) {
            echo 
"News cannot contain the pipe symbol - |";
            exit;
        }
        
$fp fopen('news.txt','a');
        if(!
$fp) {
            echo 
"Error opening file!";
            exit;
        } 
lines 104 -120. i should have full permissions to everything if there no code errors ill check to see if i do.

if i dont do you know of another way to do something similar?

Reply With Quote
  #9  
Old December 16th, 2003, 03:33 PM
TinnyFusion TinnyFusion is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 13 TinnyFusion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question I can not edit or delete news?

Hi, I have a little problem in that I can not edit or delete any news posts?

Here is a direct link here.

I have also included the source as a zip if needed.

Please help, what could be wrong?

Regards, TinnyFusion.
Attached Files
File Type: zip news.zip (2.0 KB, 329 views)

Reply With Quote
  #10  
Old December 18th, 2003, 09:43 PM
TinnyFusion TinnyFusion is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 13 TinnyFusion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

I have now totally reinstalled everything and updated all server applications to the latest as follows: Apache Server v2.0.48, ActivePerl v5.8.2.808, PHP v4.3.4, MySQL v4.0.17, and phpMyAdmin v2.5.4 but I still can not edit or delete any of my posts...?

Any help regarding this matter would be great.

Regards, TinnyFusion

Reply With Quote
  #11  
Old December 24th, 2003, 05:26 PM
TinnyFusion TinnyFusion is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 13 TinnyFusion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mmm, I turn 'register_globals' to on and everything works without any issues?

But is this not a securityrisk?

How do I get the same effect but with register_globals turned off?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Article Dicussion: Creating a News System with PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |