/    Sign up×
Community /Pin to ProfileBookmark

getting grand total from data base in form

I am trying to get the grand total in this line <input type=”hidden” name=”amount” value=”90″> instead of 90 this is the payment form that goes to worldpay and needs the grand total

[code=php]
<?php

include_once(“dbfiles/db1.php”);

$vendor = ‘wizardmotorcycl’;
$key = ‘1056199’;

$live = 100;

function sagepayform($orderid) {

global $vendor,$key,$live;

$_SESSION[‘orderID’] = $orderid;

if ($live) $vspsite=”https://secure-test.worldpay.com/wcc/purchase”;
else $vspsite=”https://secure-test.worldpay.com/wcc/purchase”;

$sql = “SELECT * FROM orders1 WHERE id='{$orderid}'”;
$result = mysql_query($sql) or die(‘ERROR:: ‘.$sql.'<br><br>’.mysql_error());

$sql2 = “SELECT * FROM config WHERE config_id=1”;
$result2 = mysql_query($sql2) or die(‘ERROR:: ‘.$sql.'<br><br>’.mysql_error());

if (mysql_num_rows($result)==1 && mysql_num_rows($result2)==1) {

$order = mysql_fetch_assoc($result);
$config = mysql_fetch_assoc($result2);

$data = array(
‘VendorTxCode’=>$order[‘id’],
‘Amount’=>number_format($order[‘grandtotal’],2,”.”,””),
‘Currency’=>’GBP’,
‘Description’=>$config[‘store_name’].’ Order’,
‘SuccessURL’=>’http://’.$_SERVER[‘HTTP_HOST’].str_replace(‘checkout’,’transok’,$_SERVER[‘REQUEST_URI’]),
‘FailureURL’=>’http://’.$_SERVER[‘HTTP_HOST’].str_replace(‘checkout’,’transnotok’,$_SERVER[‘REQUEST_URI’]),
‘CustomerEmail’=>$order[’email’],
‘VendorEmail’=>$config[‘store_owner_email_address’],
‘CustomerName’=>$order[‘title’].” “.$order[‘forename’].” “.$order[‘surname’],
‘DeliveryAddress’=>$order[‘d_street_address1’].” “.$order[‘d_street_address2’],
‘DeliveryPostCode’=>$order[‘postcode’],
‘BillingAddress’=>$order[‘cardaddress’],
‘BillingPostCode’=>$order[‘cardpostcode’],
‘ContactNumber’=>$order[‘dayphone’]
);

$crypt = base64Encode(SimpleXor(formatData($data),$key));

?>

<form action=’https://secure-test.worldpay.com/wcc/purchase’ method=post>
<input type=’hidden’ name=’instId’ value=’1056199’/>
<input type=”hidden” name=”amount” value=”90″>
<input type=’hidden’ name=’cartId’ value=’id’/>
<input type=’hidden’ name=’currency’ value=’GBP’/>
<input type=’hidden’ name=’testMode’ value=’100’/>
<input type=’submit’ value=’Submit Form’/>

<script>
window.onload=function() {
setTimeout(“document.SagePay.submit()”,3000);
}

</script>

</form>
<?php
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 21.2015 — Welcome to the forums. Note that I added the forum's nifty [noparse][code=php]...[/code] tags around your code. We also have [code=html]...[/code] and generic ...[/noparse] tags you can use.

As far as your question, if the value you want is in $data['Amount'], then it's as simple as:
[code=php]
<input type="hidden" name="amount" value="<?php echo $data['Amount']; ?>">
[/code]
×

Success!

Help @cavern spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...