I have a field named acctno that is causing me issues. When the entire account number is filled in it works perfectly
example: 72-11-51450-000-221-0000
but if you only enter : 72-11-51450-000-221
and don't fill in the last 4 zeros it doesn't come through and the POST isn't picking it up. I want it to assume the zeros if nothing is entered.
The following is all of the code pertaining to that field on the original page.
window.onload = init;
function init()
{
document.getElementById("acctno").focus();
}
$(document).ready(function(){
//using field mask for account number
$('#acctno').mask("99-99-99999-999-999-9999");
});
<td><label for="acctno">Account Number:</label></td>
<td><input id="acctno" name="acctno" size="24" maxlength="24" value="<?php echo $acctno; ?>">
</td>
The following is the code from the results page:
if (!empty($POST['acctno'])) {
//$SESSION['acctno'] = $POST['acctno']; (This was the old way I was doing it, next line was my attempt at fixing the problem, but it didn't make a difference. If I echo the $POST['acctno'] it comes back with nothing.
$SESSION['acctno'] = str_pad($POST['acctno'], 19, "0", STR_PAD_RIGHT);
}
Then I try to break it out ignoring hyphens:
$acctno = $_SESSION['acctno']; (on this line I get this in my logs - Undefined index: acctno in /www/zendsvr/htdocs/PoCo/finance/accountinquiry/acctdetail.php on line 56
$acct_fund = substr($acctno, 0, 2);
$acct_dept = substr($acctno, 3, 2);
$acct_class = substr($acctno, 6, 5);
$acct_sect = substr($acctno, 12, 3);
$acct_obj = substr($acctno, 16, 3);
$acct_proj = substr($acctno, 20, 4);
Again, if the account no. is completely filled in it works perfectly. How can I fix this for when the whole account isn't filled in? My users will do this because that is what they are accustomed to right now.
Thanks