Jump to content

One submission, getting two records


thereaper87

Recommended Posts

Hello there,

 

I have made a ban form on my website. It is all going good until I open phpmyadmin. There is two records from one submission. Usually the second record has some missing information. There should not be a duplicate and I do not understand why it is happening. If anybody could explain what is causing this would be great.

 

Here is the page.

<?php
session_start();
require_once 'database.php';
if(isset($_SESSION['mod']))
{
     $userid = $_SESSION['user'];
     if(isset($_GET['action']) && strcasecmp($_GET['action'], "file") == 0) // checks to see if form is submitted
     { 
         $username = $_POST['user'];
         $time = $_POST['time'];
         $reason = $_POST['reason'];
         $u_time = date("U");
         $r_time = date("m-j-Y g:i A");
         if($time == "00")
         { // if the time is a permaban
             $sql=mysql_query("SELECT * FROM user WHERE username='$username'") or die("Error 1");
             $data=mysql_query($sql);
             $user_ip = $data['last_ip'];
            if ($user_ip != 127.0.01)
             { // admin stuff 
                 $p_ban=mysql_query("INSERT INTO ip_ban (ip,real_time,unix_time,days_left,reason) VALUES ('$user_ip','$r_time','$u_time','99999999999','$reason')") or die("Error 2");
                 echo 'The user '.$username.' has been banned.'; 
             }else{ // if it is an admin
            echo 'You cannot ban that user.';
             }
         }else{ // not a perma ban
         if($username != "admin") // admin stuff
         {
             $temp_ban=mysql_query("INSERT INTO blacklist (email,reason,end_date,appeal,unixtime) VALUES ('$username','$reason','$time','No','$u_time')") or die("Error 3");
             echo 'The user '.$username.' has been banned.';
         }else{
         echo 'You cannot ban that user.';
         }
         }
     }else{
     $user_ban = $_GET['user'];
     if(isset($user_ban))
     {
     ?>
     <form name="file_ban" method="post" action="?action=file">
     Username: <input type="text" name="user" value="<?php echo $user_ban; ?>"><br />
     Length of Ban: <select name="time">
     <option value="1">1 Day</option>
     <option value="3">3 Days</option>
     <option value="5">5 Day</option>
     <option value="7">1 Week</option>
     <option value="15">15 Days</option>
     <option value="30">1 Month</option>
     <option value="90">3 Months</option>
     <option value="99999999999">∞ Infinity (Permaban)</option>
     <option value="00">IP Ban (Does not expire)</option>
     </select><br />
     Reason: <br />
     <textarea name="reason" cols="50" row="4"></textarea><br />
     <input type="submit" value="Ban">
     <?php


     }else{


     }




     }
}else{   // If session is not set
header("Location: index.php");
}
?>

 

If you need any explanation of what anything does, just please ask.

 

Thank you!

Link to comment
Share on other sites

A double submission can be due to something as simple as the user double clicking the submit button before the data has posted successfully , in essence submitting the form twice. If this is the case then you can either validate that the posted data hasn't been submitted already, or use some jquery / JavaScript to disable the submit button after the first click

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.