Jump to content

roice

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

roice's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. $date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y")); "create_date" and "date" created from linux time - the number of second that past since 1970. so 20 is 20 second. Will both of the 2 codes you wrote be good for checking how much time past since the last submit?
  2. The Little Guy - thanks, I'll try that. But I still don't understan how comes that I got duplicated rows in my DB... Psycho - Thanks, you are right. Usually I user 1 and 0 for true and false... About my tables - every topic can one several replies, so I create row in the DB and put its ID inside every reply that conect to this row. like in here - wer have topic called "duplicated rows in DB" with lots of replies by me , you, The Little Guy and others...
  3. Hi I'm not familar with "insert ignore" function. what does "ignore" do?
  4. Hello, I build a forum which allow user to submit support tickets. when they submit the system the the main details (title, create date, open by and etc) and insert them into table "tkts_topics". the rest of the data (ticket_id, ticket text, wrote by, attachment files) insert into another table - "tkts_replies". For some reason I found duplicated tickets. its not happened all the time. I see 2 identical records in table "tkts_topics". in the second table I see that only 1 row has added, which means that I ticket have no content. Of course I add some rules: form can't be submited if there is no titket content. form can't be submited if 10 seconds haven't been past siince the last submit. Why its keep happened for time to time and how can I fix that? Here is Insert code in case you want to check it by yourself: if ($flag == 1) { $query = "INSERT INTO `tkts_topics` (open_by, track_id, name, email, system, cat_id, client, title, status, urgency, create_date, last_update, hd_owner, prog_owner) VALUES('$open_by', '$track_id', '$name', '$email', '$system_id', '$cat_id', '$client', '$title', '$status', 'low', '$date', '$date', '$hd_owner', '$prog_owner' )"; $res = mysql_query($query); $tkt_id = mysql_insert_id(); $query3 = "INSERT INTO `tkts_replies` (tkt_id, open_by, name, text, date, visible) VALUES('$tkt_id', '$open_by', '$name', '$text', '$date', 'on' )"; $res3 = mysql_query($query3); Here is the checking code: //// check for double submiting //// $query = mysql_query("SELECT create_date FROM `tkts_topics` WHERE (client = '$client') AND (email = '$email') AND (title = '$title') AND ($date - create_date <= 20) LIMIT 0,1"); if (mysql_num_rows($query)) { echo "<div class='msg_error'>You may accidentally submited this form twice<br />Don't worry - the first form received and email with all the details was sent to you</div>"; $flag = '0'; } if (!isset($_SESSION['hdUser_id'])) // if its regular user (not helpdesk/SV ) { if ( (empty($name)) OR (empty($email)) OR (empty($cat_id)) OR (empty($client)) OR (empty($title)) OR (empty($text)) OR (empty($system_id)) ) { echo "<div class='msg_error'>You did not complete all of the required fields</div>"; $flag = '0'; } } else /////////////// if it's HD/SV { if ( (empty($cat_id)) OR (empty($client)) OR (empty($title)) OR (empty($text)) OR (empty($system_id)) ) { echo "<div class='msg_error'>You did not complete all of the required fields</div>"; $flag = '0'; } else // if all good than: { if ( (empty($name)) AND (empty($email)) ) ///// if it's HD/SV and files name+email = empties than get them from DB { $query = mysql_query("SELECT name, email FROM `users` WHERE (id = '$_SESSION[hdUser_id]') AND (valid = '1') "); $index = mysql_fetch_array($query); $name = $index['name']; $email = $index['email']; } } }
  5. roice

    Last id

    No -- auto-increment is per connection. Yes, for INSERT comand but what about mysql_insert_id() comand? what will happened if 2 users will submit together and after the INSERT comand will come the mysql_insert_id()? will they both get the same number?
  6. roice

    Last id

    Thanks, What will happened if 2 user will submit or run the INSERT function at the same time? Could var $reply_id get the same number for both of them? Roi.
  7. roice

    Last id

    OK until now I insert data to first table, and than I did select for the last ID in order to put it in another table: // Update DB $query3 = "INSERT INTO `tkts_replies` (tkt_id, open_by, name) VALUES('$tkt_id', '$user_id', '$user_name' )"; $res3 = mysql_query($query3); if (!$res3) die('Invalid query: ' . mysql_error()); else { $query4 = mysql_query("SELECT id FROM `tkts_replies` ORDER BY id DESC LIMIT 0,1"); $index = mysql_fetch_array($query4); $reply_id = $index['id']; But I bump into this new function: mysql_insert_id(); I just want to know if the new function is better for my script...
  8. roice

    Last id

    when I'm using mysql_insert_id() where can I set which table I want to check?
  9. roice

    Last id

    oh, I didn't thought about it... how LAST_INSERT_ID() works?
  10. roice

    Last id

    Hello all, In simple words - what is the different between: LAST_INSERT_ID() and mysql_insert_id() ?
  11. OK, I'll Thanks What do u think about using session for that - when user submit I open sesion the current time or even better - cookie that will destroies after 10 second when submit again I check if he have cookie. if yes this means that 10 seconds haven't been pass yet and he can't submit the form... that way I'm not using SQL queries... good idea? (If I'm, already login why do I need to write the capche every post???)
  12. smoseley - your code check if the user submit the same topic in the last hour (- INTERVAL 1 HOUR ), right? Can you right it so the check will be for the last 10 seconds?
  13. floridaflatlander - some clients use the same email for all their department. Is it ok for 2 users with the same email to submit topics at the same time. I just don't want that each one of them will submit the same topice twice...
  14. Hi smoseley, I'm not familiar with: - INTERVAL 1 HOUR What does it means? also, why did you wrote: AS `exists` ? what will it give? Do you have the code for the client side that you suggest?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.