944,123 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2212
  • PHP RSS
Jun 18th, 2007
0

Validating data in a field to a existing data stored in the database

Expand Post »
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.


Thanks.....
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dudegio is offline Offline
66 posts
since May 2007
Jun 18th, 2007
0

Re: Validating data in a field to a existing data stored in the database

after pressing submit validate fields i.e.

if ($textboxvalue == "") {
Reputation Points: 66
Solved Threads: 56
Posting Pro in Training
Fungus1487 is offline Offline
459 posts
since Apr 2007
Jun 18th, 2007
0

Re: Validating data in a field to a existing data stored in the database

after pressing submit validate fields i.e.
PHP Syntax (Toggle Plain Text)
  1. if ($textboxvalue == "") {
  2. // go back and error
  3. }
then perform an sql request (im guessing you using a database)
PHP Syntax (Toggle Plain Text)
  1. "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
Reputation Points: 66
Solved Threads: 56
Posting Pro in Training
Fungus1487 is offline Offline
459 posts
since Apr 2007
Jun 18th, 2007
0

Re: Validating data in a field to a existing data stored in the database

no idea why my first comment is there ?
Reputation Points: 66
Solved Threads: 56
Posting Pro in Training
Fungus1487 is offline Offline
459 posts
since Apr 2007
Jun 18th, 2007
0

Re: Validating data in a field to a existing data stored in the database

$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";
}
else
{
echo"pass";
}

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
pass
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dudegio is offline Offline
66 posts
since May 2007
Jun 19th, 2007
0

Re: Validating data in a field to a existing data stored in the database

Thank you very much for help..... I have made solutions based on the your suggested query.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dudegio is offline Offline
66 posts
since May 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: exec function on Windows XP
Next Thread in PHP Forum Timeline: form handling





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC