Chi Kien Uong
Geranienstraße 30
71034 Böblingen
Deutschland / Germany
|
If you are not registered or logged in, you may still use these forums but with limited features.
Show recent topics
|
|
|
Author |
Message |
02/10/2003 01:18:34
|
oavs
Beginner
Joined: 12/09/2003 05:43:48
Messages: 9
Offline
|
I have an Error code for validating my form. It is a conditional validation.
If the there is an item offered
= or < then the error message is displayed. Otherwise it records the record. b_offer is the entered value by the user and the boffer is the value retreived from the database.
When form is submitted b_offer is replaces the value in the boffer in the database based on the error validation below.
Hope some one could help me with the correct code
Thanks
Here is the code
[php]
// Error code starts here
$Error = "0"; /* set error flag to 0*/
$ErrorMsg = array(); /*create a new array to hold error messages*/
if($HTTP_POST_VARS['b_Offer'] > $HTTP_POST_VARS['bOffer']){ /* is the new offer greater than the current offer*/
$Error = "1"; /* is the new offer greater than the current offer*/
$ErrorMsg[0] = "Enter a value greater than Last Offer"; /* is the new offer greater than the current offer*/
}
if (!$HTTP_POST_VARS['bOffer']){ /* if offer is blank in the form, set flag to 1 and add message to the array */
$Error = "1";
$ErrorMsg[1] = "You must enter an Offer";
}
if (!$HTTP_POST_VARS['bName']){ /* if Name is blank set error and add message */
$Error = "1";
$ErrorMsg[2] = "You must enter your Name";
}
if (!$HTTP_POST_VARS['bSurName']){ /* if SurName is blank set error and add message */
$Error = "1";
$ErrorMsg[3] = "You must enter your SurName/Last name";
}
if (!$HTTP_POST_VARS['bEmail'] || !validate_email($HTTP_POST_VARS['bEmail'])){ /* if email address is blank or not a valid email address, set error and add message */
$Error = "1";
$ErrorMsg[4] = "You must enter a valid Email address";
}
if($HTTP_POST_VARS['b_Offer'] = $HTTP_POST_VARS['bOffer']){ /* is the new offer greater than the current offer*/
$Error = "1"; /* is the new offer greater than the current offer*/
$ErrorMsg[5] = "Offer amount can not be same"; /* is the new offer greater than the current offer*/
}
$AlbumID = $HTTP_POST_VARS['AlbumID'];
if(!$Error){ /* if there are no errors on input, we will send emails, and update or write a new message to database */
// Error code ends here
[/php]
Further down I have this code in my Form
[php]
<?php if($Error && ($HTTP_POST_VARS["MM_update"] == "updateForm")){
if($ErrorMsg[0]){
echo "<b>$ErrorMsg[0] </b><br>";
}
if($ErrorMsg[1]){
echo "<b>$ErrorMsg[1] </b><br>";
}
if($ErrorMsg[2]){
echo "<b>$ErrorMsg[2] </b><br>";
}
if($ErrorMsg[3]){
echo "<b>$ErrorMsg[3] </b><br>";
}
if($ErrorMsg[4]){
echo "<b>$ErrorMsg[4] </b><br>";
}
if($ErrorMsg[5]){
echo "<b>$ErrorMsg[5] </b><br>";
}
}
?>
[/php]
Problems are:
1.) Error messages only (incorrectly as per 2 and 3) working when there is an bOffer with a value.
2.) If the b_offer is less than bOffer , I am still getting error message saying "Offer amount can not be same
" along with the error message "Enter a value greater than Last Offer " which is correct.
3.If there is no value in the bOffer, error messages aren't working - not showing at all
You are welcome to have a look at
http://offerus.com/preport.php
|
|
|
|
|
|
Based on the open source JForum
|