We have an intertesting problem here, where the submit from the previous form works and the d/base write is committed successfuly, however the next form which should retrive the previous information returns n-1 number of records (1 less than are in the d/base). It almost as if the form looking up the information after submission has started its processing before the final write commit has been completed in the d/base (mySQL)
Details:
This problem here is that not all the records are being retrieved by the query when the variable value ($regoNum), which is retrived from the $_POST array is used in the query. It works fine (i.e correct number of records are retrieved) if the variable $regoNum is hardcode to a value. (see screen shot attached. there were 2 records in the d/base and 2 are shown and yes there is a prob with the calculation logic but I'll fix that later :? )
[attachment=0]paypalpreconf.jpg[/attachment]
As you can see from the code in Exibit#2 , $reogNum is also printed out to ensure I could retrieve it, and this works OK.
The sympotoms are as follows:
previous form (regoform4) submits and writes successfuly to the d/base. This form has the code in exibit #1 in the "On Submit code - after sending email:" section. The action is successful and the paypal preconfirmation form is shown
the issue is that the paypal preconfirmation form- in Exibit #2 - uses the variable $regoNum as the selector for which records to return.
If there is only one record that macthes the variable, no records are returned. If there are multiple records that match the variable value, then n-1 records are returned. (i.e 1 less than the record count in the d/base).
Can offer any advice here?
If you need to, you can test the process by going to http://test.wphcfc.net.au and clicking on online-registration. By clicking on the all Reports menu item (uses CC), you can see the registrations that are in the d/base.
Thanks
aj
Exibit #1
<?php
$action = JRequest::getString('rf4SBtn');
if (strcasecmp($action, 'Proceed to Payment') != 0) {
$MyForm->showForm('regoform1', $posted);
}
else {
$MyForm->showForm('paypal', $posted);
}
?>
Exibit #2 - paypal preconfirmation form.
<H3>PayPal Pre-confirmation Information</H3>
<br>
<table style="text-align: left; width: 100%;" border="0" cellpadding="1" cellspacing="2">
<tbody>
<tr>
<td style="width: 3%;text-align: center;">#</td>
<td style="width: 7%;text-align: center;">Registration ID</td>
<td style="width: 7%;text-align: center;">Name</td>
<td style="width: 7%;text-align: center;">Age Group</td>
<td style="width: 7%;text-align: center;">Student Discount Requested</td>
<td style="width: 7%;text-align: center;">Registration Charge $</td>
</tr>
<tr>
<td colspan=6><hr>
</td>
</tr>
<?php
$i=0;
$sTotal=0;
//dbase stuff here, get and render
//$regoNum = $_POST['playerRegNum'];
$regoNum = '20090615-213';
print $regoNum;
$db =& JFactory::getDBO();
$tablename = 'jos_chronoforms_wphcfc_regoinfo';
$query = 'SELECT playerRegNum,playerRegNumCtr,playerFirstname,playerSurname,playerRegoAgeGrp,playerStudent FROM jos_chronoforms_wphcfc_regoinfo WHERE playerRegNum ='.'\''.$regoNum.'\''.' ORDER BY jos_chronoforms_wphcfc_regoinfo.playerRegNumCtr ASC';
$db->setQuery($query);
$t_rows = $db->loadRowList();
foreach ( $t_rows as $t_row ) {
$i++;
switch ($t_row[4]) {
case "U6":
$amt=6;
break;
case "U7":
$amt=7;
break;
case "U8":
$amt=8;
break;
case "U9":
$amt=9;
break;
case "U10":
$amt=10;
break;
case "U11":
$amt=11;
break;
case "U12":
$amt=12;
break;
case "U13":
$amt=13;
break;
case "U14":
$amt=14;
break;
case "U15":
$amt=15;
break;
case "U16":
$amt=16;
break;
case "U17":
$amt=17;
break;
case "U18":
$amt=18;
break;
case "U19/21":
$amt=21;
case "All Age":
$amt=25;
break;
case "Prem-League":
$amt=30;
break;
case "Over35":
$amt=35;
break;
}
$amtFmtd = number_format($amt,2);
$sTotCalc = $sTotal + $amt;
$sTotal = number_format($sTotCalc,2);
?>
<tr>
<td style="width: 3%;text-align: center;"><?echo $i?></td>
<td style="width: 7%;text-align: center;"><?echo $t_row[0]?>-<?echo $t_row[1]?></td>
<td style="width: 7%;text-align: center;"><?echo $t_row[2]?> <?echo $t_row[3]?></td>
<td style="width: 7%;text-align: center;"><?echo $t_row[4]?></td>
<td style="width: 7%;text-align: center;"><?echo $t_row[5]?></td>
<td style="width: 7%;text-align: center;"><?echo $amtFmtd?></td>
</tr>
<?
$item = "item_".$i;
$amount = "amount_".$i;
print '<input type="hidden" name="'.$item.'" value="'.$t_row[0].'-'.$t_row[1].', '.$t_row[2].' '.$t_row[3].', Agegrp: '.$t_row[4].'">';
print '<input type="hidden" name="'.$amount.'" value="'.$amtFmtd.'">';
}
//penalties/discounts & total variables here
$earlyLate='early';
$early=-0.10;
$late10=0.10;
$late20=0.20;
$gTotal=0.00;
//penalty-discount calcs here
if ($earlyLate=='late10')
{
$pdDesc='10% Late Fee';
$gTotCalc = $sTotal*(1+$late10);
$gTotal = number_format($gTotCalc,2);
$pdFeeCalc = $sTotal*$late10;
$pdFee= number_format($pdFeeCalc,2);
}
elseif($earlyLate=='late20')
{
$gTotCalc = $sTotal*(1+$late20);
$gTotal = number_format($gTotCalc,2);
$pdDesc='20% Late Registration Fee';
$pdFeeCalc = $sTotal*$late20;
$pdFee= number_format($pdFeeCalc,2);
}
elseif($earlyLate=='early')
{
$gTotCalc = $sTotal*(1+$early);
$gTotal = number_format($gTotCalc,2);
//$gTotal = $sTotal*(1-$early);
$pdDesc='10% Early Registration Discount';
$pdFeeCalc = $sTotal*$early;
$pdFee= number_format($pdFeeCalc,2);
}
else
$gTotal = number_format($sTotal,2);
//p-d item creation for paypal
$itemPD = 'item_'.($i+1);
$feeAmt = "amount_".($i+1);
print '<br>';
print '<p>'.$itemPD.$pdDesc.'</p>';
print '<p>'.$feeAmt.$pdFee.'</p>';
print '<br>';
print '<input type="hidden" name="'.$itemPD.'" value="'.$pdDesc.' '.$pdType.'">';
print '<input type="hidden" name="'.$feeAmt.'" value="'.$pdFee.'">';
?>
<tr>
<td colspan=6><hr>
</td>
</tr>
<tr>
<td colspan=4></td><td align="center"><b><i>Subtotal</i></b></td><td align="center"><?php echo $sTotal?>
</td>
</tr>
<tr>
<td colspan=3></td><td align="center"><i>Extra Charges</i></td><td align="center"><?php echo $pdDesc?></td><td align="center"><?php echo $pdFee?>
</td>
</tr>
<tr>
<td colspan=4></td><td colspan=2><hr>
</td>
</tr>
<tr>
<td colspan=4></td><td align="center"><b><i>Total</i></b></td><td align="center"><?php echo $gTotal?>
</td>
</tr>
<tr>
<td colspan=4></td><td colspan=2><hr>
</td>
</tr>
<tr>
<td colspan=4></td><td colspan=2 align="center"><br>
<input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</td>
</tr>
</tbody>
</table>
//other variable for paypal submission
<input type="hidden" name="playerRegNum" value="<?php echo $_POST['playerRegNum'];?>" />
<input type="hidden" name="currencyCode" value="AUD" />
<input type="hidden" name="countryCode" value="AU" />
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="seller_1243319834_biz@optusnet.com.au">
<input type="hidden" name="currency_code" value="AUD">
<input type="hidden" name="rm" value="2">
<input type='hidden' name='quantity_1' value='1'>
<input type="hidden" name="cancel_return" value="http://test.wphcfc.net.au/index.php?option=com_chronocontact&chronoformname=paypalfail">
<input type="hidden" name="return" value="http://test.wphcfc.net.au/index.php?option=com_chronocontact&chronoformname=paypalok">