Blockchain send payments to faucetbox

0 votes

I am trying to run this code:

<?php
//custom parameters
$api_key = "my_api_key";
$userAddy = $_SESSION['user'];
require_once("faucetbox.php");
$currency = "BTC"; # or LTC or any other supported by FaucetBOX
$faucetbox = new FaucetBOX($api_key, $currency);
$users = array(
     'user_id' => clean($user_id), 
     'user_name' => clean($user_name), 
     'user_email' => clean($user_email), 
     'user_pass' => clean($user_pass), 
     'user_points' => clean($user_points), 
     'user_wallet' => clean($user_wallet)
);
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
	header("Location: index.php");
}

$selfNav = mysqli_query($conn, "SELECT user_wallet, user_points FROM users WHERE user_id=".$_SESSION['user']);
$rowNav = mysqli_num_rows($selfNav);

$rowAssoc = mysqli_fetch_assoc($selfNav);

$balance = $rowAssoc['user_points'];
$wallet = $rowAssoc['user_wallet'];

//auto cashout if bal over 0.00010000
	
if($balance > 0.00010000){
	    
$amount = $rowAssoc['user_points'];
	   	
$currency = "BTC";
		
$faucetbox = new Faucetbox($api_key, $currency);
		
$result = $faucetbox->send($wallet, $amount);
		  
if($result["success"] === true){
		  
$_SESSION['cashout'] = $result["html"];
		  
//reset balance to zero
		  
mysqli_query($conn, "UPDATE `users` SET user_points = 0  WHERE user_id = " . $_SESSION['user')];
		  		
header('Location: ../home.php');
?>

I get this error:

The bitcoinrotator.publiadds.org.pt page is not working bitcoinrotator.publiadds.org.pt can not process this request for time. 500

Sep 7, 2018 in Blockchain by slayer
• 29,350 points
461 views

1 answer to this question.

0 votes

well there it is its work but it stay with some bug there but now its work the error is Array ( [user_wallet] => 111111111111111111111111111111111111 [user_points] => 0.00000010 ) Error en balance

<?php
session_start();//Session start is ALWAYS the first thing to do.
if(!isset($_SESSION['user']))
{
	header("Location: index.php"); //Sending headers its the next thing to do. Always. 
}
include_once 'dbconnect.php';


//custom parameters
$api_key = "my_api_key";
$userAddy = $_SESSION['user'];
require_once("faucetbox.php");
$currency = "BTC"; # or LTC or any other supported by FaucetBOX
$faucetbox = new FaucetBOX($api_key, $currency);
//$users = array(
//     'user_id' => clean($user_id), 
//     'user_name' => clean($user_name), 
//     'user_email' => clean($user_email), 
//     'user_pass' => clean($user_pass), 
//     'user_points' => clean($user_points), 
//     'user_wallet' => clean($user_wallet)
//);



//You are mixing mysql and mysqli, you need to choose one. Since you are on  a shared hosting, mysqli is probably
//not installed/available, so we will keep using mysql. mysqli is safer!
$selfNav = mysql_query("SELECT user_wallet, user_points FROM users WHERE user_id=".$_SESSION['user']);
$rowNav = mysql_num_rows($selfNav);

$rowAssoc = mysql_fetch_assoc($selfNav);

print_r($rowAssoc);

$balance = $rowAssoc['user_points'];
$wallet = $rowAssoc['user_wallet'];

//auto cashout if bal over 0.00010000
	
if($balance > 0.00010000){
	    
$amount = $rowAssoc['user_points'];
	   	
$currency = "BTC";

		
$result = $faucetbox->send($wallet,$amount); //$amount);
		  
if($result["success"] === true){
		  
$_SESSION['cashout'] = $result["html"];
		  
//reset balance to zero
		  
mysql_query("UPDATE `users` SET user_points = 0  WHERE user_id = " . $_SESSION['user']);
		  		echo "result sucess and location go";
//header('Location: ../home.php');
}else{
	echo "Error on faucet";
	var_dump($result);
	//What happens if there is an error?
}
}else{
	echo "do not have enough credit to cash out";
	//what happens if they dont have enough balance?
}
?>
answered Sep 7, 2018 by Vicky

Related Questions In Blockchain

0 votes
1 answer

Not able to send payments using Blockchain API.

Try the following code. It should help ...READ MORE

answered Jul 31, 2018 in Blockchain by slayer
• 29,350 points
447 views
0 votes
1 answer

Blockchain Hyperledger private key not able to send coins

From the code you posted, if(whichType == TX_SCRIPTHASH){//pay ...READ MORE

answered Sep 14, 2018 in Blockchain by digger
• 26,740 points
453 views
0 votes
0 answers
+1 vote
3 answers

Is it possible to store data about arbitrary objects on the blockchain using smart contracts?

Basically you implement requested logic on by ...READ MORE

answered Aug 30, 2018 in Blockchain by Artem
1,242 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
1,148 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,706 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,237 views
0 votes
2 answers
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP