Author |
Message |
|
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
|
|
|
As regards to adding other sections - you don't.
Guset book adds when it reaches 10 + messages
and changing wording etc. you really need to go every file in templates and the root dir of the guest file to see which files and what word you need to change.
It is a start anyway. :lol:
|
|
|
Looks great. I love the Human Verification system you have.
Any chance of the code ?
Have a look at mine I have also added some fields
http://www.oavs.com.au/guestbook/addentry.php
In the view I also implimented all the added fields. Check things like 'profession and country'
http://www.oavs.com.au/guestbook/index.php
|
|
|
I like to know as well. Whichtemplate needs to be edited to include additional fields?
|
|
|
Do you know how and where to add fields to the form?
|
|
|
It's fine now. ..you tricky coder thingy mingy you :-)
|
|
|
Can you please let me know how you got the images showing up ?
Thanks
|
|
|
I will sign it if the link worked. I like to know how you got the images working. I am so surprised that many not answering this question. It is either too hard or too easy.
FO
|
|
|
I can not get it to show images icons that came with the Advance Guestbook. can some one please give me hand.
Thanks
Here is the URL
http://www.oavs.com.au/guestbook/addentry.php
and the config code
|
|
|