php


how do i insert data into mysql database and at the same time send the data to another page using curl


so what i'm trying to do here is to insert the client's info into my database and then send the data to the bank for money transaction. this way i can keep track of people who filled out the form and hit the "pay" button but did not actually pay.
here i'm using $_POST['stat'] value that i posted via a hidden value in my html form in the same page. so when the page refreshes and " $_POST['stat'] == 1 "i run the query and successfully sumbit the form values into my database. (this part of the code works)
then i check if $r has a value so if data insertion is done i can transfer the values to the bank website using the bank's API. which sends the data using curl. it must redirect the page and send the values and redirect the page back so i can verify it.(not including the verification script here)
<?php
if($_POST['stat'] == 1){
$q = "INSERT INTO database(*tables*) VALUES
(*values*)";
$r = mysqli_query($dbc, $q);
// $r has a value and successfully submits data into the database
if($r){ //codes below wont't run even though r has a value
function send($api, $amount, $redirect, $factorNumber=null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://url');
curl_setopt($ch, CURLOPT_POSTFIELDS,"api=$api&amount=$amount&redirect=$redirect&factorNumber=$factorNumber");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
$api = 'API';
$amount = 'Amount';
$redirect = 'Callback';
$factorNumber = 123;
$result = send($api,$amount,$redirect,$factorNumber);
$result = json_decode($result);
if($result->status) {
$go = "https://url";
header("Location: $go");
} else {
echo $result->errorMessage;
};
};
}
?>
but even though $r has a value the bank's API wont work. so if i write :
if($r){echo 'success';}
it echos out success and if i run the bank's API separately it will also run. i have no idea why but this won't work. the data will be submitted to the database but won't redirect the page to the bank. any idea how to fix this?
thanks in advance

Related Links

Facebook SDK PHP login “Bad Request”
mysql/php merging/combining row values
Saving data to Database from HTML Input
unexpected 'else' (T_ELSE) on an empty line [duplicate]
PHP Email Script won't send email [duplicate]
Buddypress ORDER BY custom sort option on members directory
WordPress Update User Meta Front End Profiles
How to return a MySQL string from within a PHP function?
Error in file upload with sonata-admin bundle
combining multiple mysql_num_rows queries by using count in a single table
Bootstrap 3 responsive table code replacement in Wordpress custom theme
Pull number of rows from a SQL query and put it in PHP as a variable?
Phpscript to do time countdown not working properly
preg_replace, the /e modifier is deprecated [duplicate]
Deleting saved failed attempts of the non existing users when throttling login
Amazon MWS API returning SignatureDoesNotMatch

Categories

HOME
cocoapods
windows-8.1
ontouchlistener
ant
out-of-memory
twitter-fabric
openflow
vue-resource
jint
bittorrent
angular2-template
stack-overflow
migrate
fasm
smooks
jpa-2.0
asp.net-core-1.0
hidden
word2vec
salt-cloud
home
pfobject
web-analytics
rxjs5
points
echosign
tortoisehg
ninject
region
docx4j
autodesk-model-derivative
opnet
android-collapsingtoolbar
serversocket
jfxtras
assertions
spinner
cordys-opentext
love2d
nanogallery
elastica
django-smart-selects
llvm-ir
text-decorations
sbjson
sendinput
music21
rightnow-crm
swift2.3
.net-micro-framework
directwrite
ol3-google-maps
non-linear-regression
lightning-workbench
skip-lists
htmlspecialchars
clrs
adobe-reader
msg
openquery
fuzzer
clp
android-syncadapter
django-redis
onepage-checkout
android-expansion-files
flush
myfaces
pack
helm
textpattern
html.actionlink
apache-commons-digester
jnlp
featuretoggle
360-degrees
wlanapi
android-handler
shoes
gflags
datagridcomboboxcolumn
flurry-analytics
window-resize
category-theory
nosql-aggregation
profiles
facebook-game-groups
jmenubar
hints
indesign-server
bcdedit
nsmutablestring
coordinate
jdom
opends
dropshadow
differentiation
drawimage
representation
kernel32
webresponse
git-log
spring-modules
main-method
objectinstantiation

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App