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

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 August 4th, 2003, 12:38 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
It keeps on posting..help

<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry">

when i used this method, a form that will post to itself, it seems to add new newsentry when i refresh my browser.

Can anyone help me how to prevent this

Reply With Quote
  #2  
Old August 4th, 2003, 03:14 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You have to separate the posting code from the display code, something like the following:

PHP Code:
if($_POST){
    
//Do the code to insert into the database and reprint the current page or a success page.
}
else{
    
//Do the code to print the form.


Reply With Quote
  #3  
Old August 4th, 2003, 09:14 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
how about this

if(!empty($_POST['submit']))
{
//insert to database
// Display inserrt message
}
else
{
?>
<form method="post" action="" name="ot">
<input type="text" name="action" value="New Entry">
<input type="submit" name="ADD" value="SAVE">
</form>
<?
}

//When you refresh your browser after submitting new entry, it will submit again..

Thank you for any replies

Reply With Quote
  #4  
Old August 5th, 2003, 07:54 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Why not try it the way I first recommended? When I changed !empty($_POST['submit']) in your code to just $_POST, it worked like a charm.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > It keeps on posting..help


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 2 hosted by Hostway
Stay green...Green IT