Hello!
The site has already started a session and when im at the end of the inputs, I made a new form action. After the new form action i want it to remember the old session, so all can be calculated, not only the last page.
Here is the main code (payment.php)
<?
session_start();
include_once ("config/config.php");
include_once ("gateway.php");
include_once ("redirect.php");
if ($_REQUEST['table']==1) $_SESSION['table_to_modify']="users";
if ($_REQUEST['table']==2) $_SESSION['table_to_modify']="auctions";
if ($_REQUEST['table']==3) $_SESSION['table_to_modify']="winners";
if ($_REQUEST['table']==4) $theoption=2;
// assign posted variables to local variables
// note: additional IPN variables also available -- see IPN documentation
$payment_gross = $_POST['amount'];
$txn_id = "Test Transaction";
$custom = $_POST['custom'];
$currentTime = time();
if ($payment_status == "Completed"){
#-------------------------------------------
if ($theoption==2) {
$currentBalance = getSqlField("SELECT balance FROM users WHERE id='".$custom."'","balance");
$updatedBalance = $currentBalance - $payment_gross;
if ($updatedBalance<=0) {
$_SESSION['accsusp']=0;
}
$currentTime = time();
$updateUser = mysql_query("UPDATE users SET
active='1', payment_status='confirmed', balance='".$updatedBalance."' WHERE id='".$custom."'");
$updateAuction = mysql_query("UPDATE auctions SET
active='1' WHERE ownerid='".$custom."'");
$insertInvoice = mysql_query("INSERT INTO invoices
(userid,feename,feevalue,feedate,balance,transtype,processor) VALUES
('".$custom."','".$lang[payment_fee]."','".$payment_gross."','".$currentTime."','".$updatedBalance."','payment','".$setts['payment_gateway']."')");
} else {
if ($_REQUEST['table']==3) {
$updateTable = mysql_query("UPDATE ".$_SESSION['table_to_modify']." SET
active = '1',payment_status='confirmed',amountpaid='".$payment_gross."',paymentdate='".$currentTime."',
txnid='".$txn_id."',processor='".$setts['payment_gateway']."' WHERE auctionid='".$custom."'") or die(mysql_error());
} else {
$updateTable = mysql_query("UPDATE ".$_SESSION['table_to_modify']." SET
active = '1',payment_status='confirmed',
amountpaid='".$payment_gross."',paymentdate='".$currentTime."',
processor='".$setts['payment_gateway']."' WHERE id='".$custom."'") or die(mysql_error());
}
}
echo "<script>document.location.href='".$_POST['return']."'</script>";
}
?>
gateway.php is accepted, cause there is no post functions there.
And here is the redirect.php (thats causing the main code session to die)
<?php
session_start();
// Definiera konstanter för databasanslutning
include_once ("config/config.php");
// Definiera koders livslängd, i sekunder
$CODE_LIFETIME = 24*60*60;
// Definiera vilken sida/adress man hamnar på vid godkänd kod
//$LOCATION = 'paymentsimulatororg.php';
// Definiera felmeddelande
$ERROR_MSG = 'Felaktig kod.<br>';
// Stäng av PHP:s felrapportering
error_reporting(0);
// Anslut till databasen
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
// Användaren tryckte på login-knappen
if ( isset($_REQUEST['submit']) ) {
// Radera utnyttjade koder som är äldre än $CODE_LIFETIME
mysql_query('DELETE from smspay WHERE (used=1) AND (tstamp-now()+'
. $CODE_LIFETIME . ' < 0)');
// Kontrollera om koden är giltig (plocka också ut eventuell 'used'-flagga)
$res = mysql_query('SELECT used FROM smspay WHERE code="'
. addslashes($_REQUEST['kod']) . '"');
// Kod fanns i DB
if ( mysql_num_rows($res) > 0 ) {
// Om det är första gången koden används (used=0) - påbörja nedräkning
if (mysql_result($res,0,0) == '0') {
mysql_query('UPDATE smspay SET used=1, tstamp=now() WHERE code="'
. addslashes($_REQUEST['kod']) . '"');
}
// Om koden är godkänd ge detta värde.
$payment_status = "Completed";
// Kod fanns ej i DB, sätt felmeddelande
} else {
$error = $ERROR_MSG;
}
}
?>
<? if (isset($error)) echo $error; ?>
<form action=payment.php method=\"post\">
Kod: <input type="text" name="kod"><br>
<br>
<input type="submit" name="submit" value="Aktivera">
</form>
Session from sellitem -> payment.php is not saved when using redirect.php action post.
Setup.
1.Sellitem.php (choose what to buy)
2.payment.php (calculates the price and deal is off if $payment_status = "Completed"; should be outputed from redirect.php when enter paycode.