Hello guys!

I am editing a program regarding billing system done in Php and MySQL and generated using the Code Charge Studio. I have problem in validating a newly entered data. What i want is to check if the billing statement number is existing or not and will not saved after validation. Saving will be done after it has pass all the validation and when save button is click. If it is existing, there will be a message displaying that it will not accept the newly entered data for the fact that it is stored in the database. If the billing statement number is available, it will go next page and later will be saved.

Also please help me on how to erase the data stored in a variable to prevent inserting to database when refresh and Back button is pressed. please help.


after pressing submit validate fields i.e.

if ($textboxvalue == "") {

after pressing submit validate fields i.e.

if ($textboxvalue == "") {
  // go back and error

then perform an sql request (im guessing you using a database)

"SELECT * FROM databasename WHERE statementnumber = " . $statementnumber . ";";

then check if a result is returned.
if one is then you know you have a result in the database with this number and you can refer the user to whichever page required.

also you will not need to empty any variables as you will always perform this check and if there is a value and they press back it will falg a record is already in the database. Hope this helps

no idea why my first comment is there ?

$fldbsnum = get_param("bsnum");
echo "bsnumber: $fldbsnum";
$queryvalidate = mysql_query("select (bs_number) from billingstatementhistory where bs_number = $fldbsnum");
echo "result: $queryvalidate";

if (mysql_query($queryvalidate) == true) {
echo "The billingstatement exists";

Hello! here is my test code in validating for the existing bsnum. it does not evaluate the first condition even the newly entered bsnum is existing. pls help me........

The output is:

bsnumber: 000001
result: Resource id #13

Thank you very much for help..... I have made solutions based on the your suggested query.