Help me function issues

Li1M0ST3Rz

I <3 Bianca
Sep 13, 2010
269
166
so ive coded a script to insert into database in a function way and it accidentally inserted 4x with one click.

Script:
PHP:
$user = new User($this->con);
                $block_io = new BlockIo($this->apiKey, $this->version);
                if(!empty($_POST['deposit']))
                    {
                        $deposit = floatval(ltrim($_POST['deposit'], '$'));
                        if($deposit >= $this->core("deposit_limit"))
                            {
                                $temp = $this->randomStrings() . '-' . $user->row("username");
                                $sql = "UPDATE `accounts` SET `temp_address`='".$temp."' WHERE `username`='".$user->row("username")."'";
                                $upd = $this->con->query($sql);
                                if(!$sql)
                                    {
                                        $this->messages[] = array('loadup' => '<div class="alert alert-warning">Error contact site coder!</div>');
                                    }
                                else
                                    {
                                        $newAddress = $block_io->get_new_address(array('label' => $temp));
                                        $execute = $newAddress->data->address;
                                        $txid = sha1($execute);
                                        $time = date("m.d.y");
                                        $this->con->query("INSERT INTO `btc_history`(`id`, `txid`,`label`,`btc_address`, `usd`, `username`, `date`, `status`) VALUES ('','".$txid."','".$temp."','".$execute."','".$deposit."','".$user->row("username")."','".$time."','')");
                                        
                                        $this->messages[] = array('loadup' => '<div class="alert alert-success" role="alert">Successfully generated bitcoin address!</div>');
                                    }
                                }
                        else
                            {
                                $this->messages [] = array('payment' => '<div class="alert alert-warning" role="alert">You enter a low deposit amount please fill in</div>');
                            }
                    }
                else
                    {
                        $this->messages[] = array('payment' => '<div class="alert alert-warning" role="alert">Error the deposit input is empty!</div>');
                    }
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Your form shouldn't use !Empty it should use isset and go off the button not the value box.
You also need to properly filter that , not just trim it
 

Li1M0ST3Rz

I <3 Bianca
Sep 13, 2010
269
166
Your form shouldn't use !Empty it should use isset and go off the button not the value box.
You also need to properly filter that , not just trim it
i’ll see if that will work, hopefully it does.
 
i’ll see if that will work, hopefully it does.
doesn’t work it need to be callled one time i am thinking i don’t know how to do that.
 

Users who are viewing this thread

Top