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

FFmpeg failed to transcode - Error while opening encoder for output stream
need ideas for remote authentication (Wordpress) [closed]
get parent array name after array_walk_recursive function
How To Insert From Data From PHP to MySQL DB
Form, receive variables on same php file [duplicate]
Arrays and nested foreach
Sidenavigation. Load everything with one request or splitted?
Display TinyMCE inputted text causing undisplayable characters
how to echo a node value (not atribute)
Cakephp Not validating data in Form
Regex Substring Negation
Selecting style attribute with REGEX in PHP
Convert SQL to active record in CodeIgniter
Wamp run as standard user?
PHP Curl followlocation working from command line but not from browser
Magento folder change

Categories

HOME
rust
list
softlayer
postgresql-9.4
website
typeerror
mongoid
dronekit-python
web2py
lvm
openflow
turbojpeg
javafx-8
ui-automation
save
sharepoint-online
rangy
createjs
pywinauto
uima
c#-7.0
exe
scala-ide
robolectric
susy-sass
adobe-illustrator
node-webkit
akka-persistence
gollum-wiki
react-dnd
points
amazon-iam
monitor
locks
instructions
xerces-c
cups
ftp-server
jslint
praat
data-uri
system-on-chip
viewcontroller
opal-framework
notesview
destroy
password-hash
android-sharing
gnome-terminal
portability
email-forwarding
mpmovieplayercontroller
maatwebsite-excel
controllers
e
zynq
mathml
wicked-pdf
apache-pig-grunt
strpos
frame-grab
jemdoc
trust
univocity
flush
certificate-authority
textpattern
perceptron
gql
dynamics-ax-2012-r2
sequence-sql
alwayson
wicked-gem
html-escape-characters
findersync
sunos
famo.us
vs-unit-testing-framework
window-resize
webautomation
coding-efficiency
rpg
windows-messages
senchatouch-2.4
lsa
jmenubar
visual-c++-2005
grails-2.3
yii-booster
virtual-channel
apportable
blobstorage
flv
web-frameworks
image-formats
getopt-long
uitextfielddelegate
firebird1.5
series-40
algol68
type-safety
dip
formal-semantics
sscli
j2mepolish
self-tracking-entities
oracle-pro-c
tacit-programming

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App