TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-29-2009, 08:08 PM   #1 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Box What is causing Duplicate Entries

Hi all,

I have simple form that puts data into a DB table. For some reason, it always gives me two entires. I cannot find why it would do that in the code anywhere. Here's my snipit:


PHP Code:
if(isset($_POST['go'])){
   
$atitle   =    mysql_real_escape_string($_POST['articleTitle']);
   
$abody =    mysql_real_escape_string($_POST['articleBody']);
   
$acategory =    mysql_real_escape_string($_POST['articleCategory']);
   
$atags =    mysql_real_escape_string($_POST['articleTags']);
   
$aauthor =    mysql_real_escape_string($_POST['articleAuthor']);   
   
$alink =    mysql_real_escape_string($_POST['articleLink']);
   
   
   if(!
get_magic_quotes_gpc())
   {
      
$atitle   addslashes($atitle);
      
$abody   addslashes($abody);
      
$atags   addslashes($atags);
   }
   include 
'config.php';
   include 
'opendb.php';

   
$query " INSERT INTO jf_posts (title,bodytext,category,tags,author,link) ".
            
" VALUES ('$atitle', '$abody', '$acategory', '$atags', '$aauthor', '$alink')";
   
mysql_query($query) or die('Error ,query failed');

   include 
'closedb.php';

   echo 
"<div id='topbar' align='center'>Article '$title' added!</div>";

__________________
SkiLeases.com

Last edited by codefreek : 07-30-2009 at 03:11 PM. Reason: PHP tags added - please read http://www.talkphp.com/lounge/4563-prettifying-pasted-code-talkphp.html
buildakicker is offline  
Reply With Quote
Old 07-29-2009, 11:27 PM   #2 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Does closedb.php contain a mysql_query()?
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 07-30-2009, 02:50 AM   #3 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

i am guessing there is something in the includes files (specially closedb.php) that might be accessing the same $query variable to make a query.
tony is offline  
Reply With Quote
Old 07-30-2009, 02:29 PM   #4 (permalink)
The Acquainted
 
Join Date: Sep 2007
Posts: 126
Thanks: 4
Sam Granger is on a distinguished road
Default

Either what has already been said, or double clicking of button, maybe even using back button. Do you always get duplicate entries?
Sam Granger is offline  
Reply With Quote
Old 07-30-2009, 03:23 PM   #5 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

I feel like an idiot. You guys are on it. I do have a query in closedb.php... bah!

Thanks for replying!
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 07-30-2009, 04:00 PM   #6 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

happens to the best of us ... (personal experience)
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
FIle permissions causing problems lrichmond Absolute Beginners 3 01-26-2009 03:17 AM
Nginx Rewrite Causing Wrong Path for PHP Script stewart General 0 11-09-2008 12:32 AM
mod_rewrite causing issues oMIKEo General 2 05-05-2008 08:54 PM
Duplicate Pagination Dan Feedback 2 02-26-2008 04:15 PM


All times are GMT. The time now is 12:35 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design