Server Side Validation with PHP

elehost 23 Jan, 2009
Hello,

I am testing the server side validation with code like this:
<?php

$isccvalid = '0';

if($isccvalid == '0'){
   return 'We were unable to complete the submission.';
}

?>


When I submit the form I am assuming I will get returned with the above error but nothing happens. I turned on the DEBUG and no errors are present.

This is with ChronoForms V3 on Joomla 1.5.9

Any advice or am I doing it wrong?

Thanks,

Paul
GreyHead 23 Jan, 2009
Hi elehost,

Looks OK here - form has your code and a submit button only.

Bob
elehost 23 Jan, 2009
Hi Bob,

Thanks for your reply.

I figured out what was wrong. There was a patch made to the code that tried to deal with an issue of the security code inappropriately showing an error. This unfortunately led to the error above.

I had implemented the hack on this post : http://www.chronoengine.com/forums.html?cont=posts&f=3&t=11843&start=30#p19924

Well in looking at the code it is clear why the hack is not complete as it will break the server side php display and only allow the spam image error to work.

<?php if(($session->get('chrono_verification_msg', '', md5('chrono')))&&(JRequest::getVar('cf_wrong_security_code') == 1)){ ?>


So I will work a bit to find the correct hack for 3.0 as once the session error is set with the current code it always displays the error on the form when you navigate to it.

.... Edited later ...

And here is the fix:

Add this to line 193 in /components/com_chronocontact/chronocontact.php above the the line:

$session->set("chrono_verification_msg", $returnval, md5('chrono'));


So it now reads:

JRequest::setVar('cf_wrong_php_verification', 1);
$session->set("chrono_verification_msg", $returnval, md5('chrono'));


I also realized the code for the submission limit would be broken too so I have edited the suggested fix for this too:

At line 154 below

$session->set("chrono_verification_msg", 'Sorry but you can not submit the form again very soon like


Add...

JRequest::setVar('cf_submission_limit_reached', 1);


-------------------------------------------------------

And then modify the hacked code to include these two new flags an an option:

edit /plugins/content/chronocontact.php around line 296 from

<?php if(($session->get('chrono_verification_msg', '', md5('chrono')))){ ?>


to

<?php if(($session->get('chrono_verification_msg', '', md5('chrono')))&&((JRequest::getVar('cf_wrong_security_code') == 1) || (JRequest::getVar('cf_wrong_php_verification') == 1) || (JRequest::getVar('cf_submission_limit_reached') == 1))){ ?>


And edit /components/com_chronocontact/chronocontact.html.php near line 273 from

<?php if(($session->get('chrono_verification_msg', '', md5('chrono')))){ ?>


to

<?php if(($session->get('chrono_verification_msg', '', md5('chrono')))&&((JRequest::getVar('cf_wrong_security_code') == 1) || (JRequest::getVar('cf_wrong_php_verification') == 1) || (JRequest::getVar('cf_submission_limit_reached') == 1))){ ?>


I hope this helps someone.

All is now well on my end and I am sorry for taking your time on the issue of the error not showing.

Cheers,

Paul
GreyHead 24 Jan, 2009
Hi Paul,

Excellent, delighted that it's fixed and I hope that Max will pick up your bug-fix for the next version.

Bob
Max_admin 25 Jan, 2009
Thanks Paul, I will check it!

moving to bugs!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
elehost 26 Jan, 2009
Hi Max,

Thanks for your reply. I would be very grateful if you are able to incorporate this fix into a future version to avoid having to reapply this. I had to edit my above post to add the coding for the Submission Time limit error to also work. I also see the need for a similar modification to the upload feature error and for that matter any other error once the code is changed. I am sure there is probably a more efficient way to do this but I liked the idea of being able to track specifically which error was being presented for full flexibility.

One very small other thing I noticed was the error message for the Submission Time limit is not able to be modified in the actual form or configuration. It would be fantastic if this was able to be modified in Joomla. I also noticed that if you submit the form with an incorrect verification code and also have the time limit set you have to wait for that time to elapse before being able to submit a new code. This poses a bit of usage problem when you combine these two useful features.

I think Chronoforms is really a great component! After getting the error messages resolved I was able to fairly easily implement GPG/PGP within chronoforms and it works like a charm.

Cheers,

Paul
Max_admin 27 Jan, 2009
Hi Paul,

Thank you, I will look at all the changes on time!🙂

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger