PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

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:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 17th, 2003, 10:03 AM
steve55 steve55 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: UK
Posts: 44 steve55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to steve55 Send a message via Yahoo to steve55
Updating Text Files with PHP

I have a news script that updates a dat file through a form, enabling a web site owner to add news articles to their site.

However I would also like them to be be able to delete (and maybe edit) any articles they post. The script seems very basic...


<?

if($_POST["do"]=="addnew") {
$fp=fopen("news.dat","a");
$formatted=ereg_replace("\r\n","<br>",$_POST["news"]);
$formatted=ereg_replace("\n","<br>",$formatted);
$newsto=date("d M Y")."%~#".$_POST["title"]."%~#".$formatted." \n";
fwrite($fp,StripSlashes($newsto));
fclose($fp);
echo " News Article added successfully.";
}
?>



(the form)

<form name="form1" action="<?echo $_SERVER['PHP_SELF']?>" method=post>
<p align="left"><?echo date("d M Y");?></p>
</form>
<form name="form1" method="post" action="<?echo $_SERVER['PHP_SELF']?>">
<p align="center">Title :
<input type="text" name="title" size="35" style="border-styleutset;">
</p>
</form>
<form name="form1" action="<?echo $_SERVER['PHP_SELF']?>" method=post>
<p align="center">
<textarea name="news" rows="13" cols="39" style="border-styleutset;"></textarea>
</p>
<p align="center">
<input type="submit" name="formbutton1" value="Add News" style="border-styleutset;">
<br>
&nbsp;</p>
<input type="hidden" name="do" value="addnew">
</form>


-----------------------------------------------------------------------------------

Can someone show me how to create two new versions of this form - one for editing and one for deleting.

Reply With Quote
  #2  
Old February 17th, 2003, 12:18 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
A simple link or image would allow you to embed the href that you need.

I notice you evaluate $_POST["do"]=="...
Try adding $_GET["delete"]==1 or something similar
from a link or image href, evaluate that first, and if true, then the user wants to use the delete function.

It shouldn't be too much harder than that.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Updating Text Files 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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway