PDA

View Full Version : No error message on error page by using ABVFP?



jjmao1
04-28-2007, 05:20 PM
If I fill in the form incorrectly in anyway, an error page is generated. But there is no any error message displayed.

In errorpage.php:
$error = $_SESSION[error];
...
echo $error;

In dbts_abvfp.php
$_SESSION[error] = $nderror;

I tested dbts_abvfp.php. The value passed from $nderror to $_SESSION is correct. dbts_abvfp.php calls errorpage.php successfully. But $_SESSION[error] is empty in errorpage.php. Obviously, the value is not passed from dbts_abvfp.php. to errorpage.php. This is original code from ABVFP. Anyone can help? Can anyone using ABVFP generate correct error message?

Jay
investmentinstock.com

navaldesign
04-28-2007, 09:12 PM
Please make sure that you have pasted in the errorpage html code, in the Start of Page tag, the following code:

<?php
session_start();
$error = $_SESSION[error];
?>

If you haven't then the error page is NOT receiving the error from abvfp.

And, yes, ABVFP correctly generates error messages in kore than 1500 sites, where it has been installed by now.

jjmao1
04-30-2007, 02:01 AM
Navaldesign,

Thank you for your response. I did copy the exact code as you did:

<?php
session_start();
$error = $_SESSION[error];
?>

and I had
<?php echo $error; ?>
as initial value of textarea and I had the php as the file extension for errorpage. I got an empty error message box. I tried a couple of way to test the value of $_SESSION[error] or error before and after the assignment, such as:
1.
<?php
session_start();
echo $_SESSION[error];
$error = $_SESSION[error];
?>

2.
<?php
session_start();
$error = $_SESSION[error];
echo $error;
?>

3.
<?php
session_start();
if(isset($_SESSION[error]))
$error = $_SESSION[error];
else
$error = "My String";
?>

In the first two cases, nothing is printed out at the top left corner of web page. In the third case, "my String" is printed out instead of error message. That means $_SESSION[error] is not defined here. Where and how do I define this variable?

Appreciate any help.

Jay

http://investmentintstock.com

navaldesign
04-30-2007, 07:14 AM
$_SESSION[error] is defined by dbts_abvfp.php at the moment of validating the fields and/or validating the origin of the submission (for antispam protection).

I can't say what the problem might be. I would need your loggin details to have an inside look and see what's going wrong.
If you wish, you can send these details through my contact form (http://www.dbtechnosystems.com/contact.php).

Edit:
However, i have tried your form, and I DO receive the error messages in your error page.

One possible reason is that you have set your browser NOT to accept cookies (and this inluded also sessions) and this might be might be causing the problem, as the error message is NOT passed through to the error page.

jjmao1
04-30-2007, 02:13 PM
Navaldesign,

Thank you for your help. I have been working on Firefox since last week. You reminded me this when you said that the error page works for you. I tested on Window IE. It works! But it does not work on Firefox. I checked my setting on Firefox. It does receives cookies. Actually, I haven't changed my Firefox setting since I downloaded last week. So, now the problem is not coding. It is browser. Many people use Firefox now. It could happen to other people too.

BTW: My error page will print out a hardcode string like this "Fields with * are required or Email address is not in correct format." if an automatic generated error message cannot be printed out on Firefox.

jjmao1
investmentinstock.com

navaldesign
04-30-2007, 03:11 PM
Hmm..... here is the solution to your problem.

ABVFP will give an error message without error, because it FF will not allow it to die.

the reason: your links miss the www. You only have http://investmentinstock.com without the www.

Please edit your links, in your menubar. Otherwise, if a user submits and the script finds a non common error (like having a @ symbol in a type -A field) he will NEVER be able to understand what is wrong.

Tested it in FF with and without the www and in the first case (with www) it works grea, in the second i get the default message that you have added in the script.

Or, second solution, change the link to the error page (in ABVFP control panel) to be http://investmentinstock.com/errorpage.php which would guarantee the continuation of the session between contact page, abvfp, and error page.

jjmao1
04-30-2007, 07:42 PM
Navaldesign,

I took your second solution. It worked for the first form of my primary domain and addon domain. But there are some problems for the second form of my primary domain. I do get error message if any field is missing or is wrong format. But the error message is always "The field Comments is missing" no matter what error is. I tried two ways:

I put following files:

dbts_abvfp.php
dbts_ABVFP_config.php
thank-you.html
error-page.html

1. under /public_html
2. under /public_html/ABVFP
and change administration script accordingly.

I got the same result. The error message does not change. The thank you page works fine. Any special treatment for forms other than the first form for the same domain?

jjmao1
chinese-translator.org

navaldesign
04-30-2007, 08:18 PM
Please provide link to the problematic form.

jjmao1
04-30-2007, 09:43 PM
The link is:
chinese-translator.org/application-form.html

jjmao1

navaldesign
04-30-2007, 10:02 PM
You have exactly the same issue here. If you go to your contact page using www, it will not work, if you go without www. it will work.

jjmao1
05-01-2007, 03:01 AM
I see it. I accidentally included www in the link to application form. So, the second solution works as long as a user does not manully type in URL with www directly to the form page. That is good enough for me. The chance which somebody type in an url with www directly to form pages is slim to none.

There is a problem for listbox. It is a required field for both contact form and application form. If none of them is selected as initial state and an user does not select an item, an error message should be given. But it is not the case now. You can try your own contact form page or the contact form page coming with the software package. This field seems is not validated.

jjmao1
chinese-translator.org/contact-us.html
chinese-translator.org/application-form.html

navaldesign
05-01-2007, 06:38 AM
List boxes, as well as checkboxes and radio buttons can NOT be by default validated with ABVFP.
This is because the listboxes have already a default value anyway (Please select .... or similar) and radio buttons - checkboxes because they do not even exist in the $_POST array if they are not checked, and ABVFP is a GENERIC form processor and not a customized one to suit excactly your own needs.

There are some ways to validate those elements:

1. For the listboxes, use the embedded BV's javascript validation

2. For check boxes and radio buttons:. use one of the many Javascripts you can easily find on the net.

3. Add some validation code in ABVFP :




//---- Required uploaded file field
if ($dbts_Formid == xx) {
$File1_Name = ($_FILES['File1']['name']);
$File1_Size = ($_FILES['File1']['size']);
if ($File1_Size == 0 or $File1_Name == "") {
$nderror .= "File 1 Upload is required.\n";
}
//---- Required checkbox field
$checkbox1 = $_POST['checkbox1'];
if ($checkbox1 == "") {
$nderror .= "Ceckbox1 is a required field.\n";
}
//---- Required radiobutton field
$radio1 = $_POST['radio1'];
if ($radio1 == "") {
$nderror .= "Ceckbox1 is a required field.\n";
}

//---- Required select list
$select1 = $_POST['select1'];
if ($select1 == "Please select one") {
$nderror .= "Please select a ..(country or whatever else).\n";
}


//---- Required aggreement to terms and conditions
$radio2 = $_POST['radio2'];
if ($radio1 != "Yes") {
$nderror .= "You did NOT agree with our Terms and Conditions.\n";
}

// Password - conform passwod validation
$Password = $_POST['Password'];
$Password1 = $_POST['Password1'];
if ($Password != $Password1) {
$nderror .= "Please check again the password fields.\n";
}
}



This code should be added just at the end of the validation part, before these lines:




if ($nderror != "") {
$_SESSION[error] = $nderror ;
header("Location: $errorpage");
exit;
}


Of course, you need to change the xx in the first line, to be the relevant Form ID number, and you should change the filed names to your actual ones.
In the selection list validation, the part in blue(Please select one) must be exactly as you have it in your listbox.