Dear all,
In my application I have to perform the following actions.
1) I have to validate 5 text boxes whether they contains valid data or not(means it should accept text only).
2) Even any one of them contains valid data and remaining boxes contains invalid data, the program should not insert those values in database.
3) If any one of the boxes contains valid data and remaining are empty, then it should allow to insert those valid values into database.
For this, I wrote a code segment like this. But a major drawback in this code is: I am able to fulfil first and second but I could not overcome the third problem.
Hence I request all of you to please look at the code and correct me in this aspect.
if ($pname1!=='')
{
if(!(preg_match('/[0-9]$/',$pname)))
{
echo " You have some error";
}
else
{
$persql = "INSERT into $pntableperson_details
VALUES ('','$pname1','$ptitle1','$semgetid','" . pnUserGetVar('uid') . "')";
$perresult = $dbconn->Execute($persql);
}
}
if ($pname2!=='')
{
if(!(preg_match('/[0-9]$/',$pname)))
{
echo " You have some error";
}
else
{
$persql = "INSERT into $pntable[person_details] ($percolumn[personid],$percolumn[personname],$percolumn[persondetails],$percolumn[semregid],$percolumn[pnuid])
VALUES ('','$pname2','$ptitle2','$semgetid','" . pnUserGetVar('uid') . "')";
$perresult = $dbconn->Execute($persql);
}
}
with warm regards,
Indrajit.