Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> JavaScript
Author Message
killing-hours
RavenNuke(tm) Development Team



Joined: Oct 01, 2010
Posts: 438
Location: Houston, Tx

PostPosted: Fri Nov 12, 2010 1:43 pm Reply with quote

Hey all-

Here to pick your brains again.

Working on the last few legs of this contact form and I'm just about there...having a bit of a time debugging on last part.

On my form it's using two random numbers to generate a verification code to determine human or not. On submit... it goes to a submit.php to do some error checking....

Code:
$err = array();


if(!checkLen('name'))
   $err[]='The name field is too short or empty!';

if(!checkLen('email'))
   $err[]='The email field is too short or empty!';
else if(!checkEmail($_POST['email']))
   $err[]='Your email is not valid!';

if(!checkLen('subject'))
   $err[]='You have not selected a subject!';

if(!checkLen('message'))
   $err[]='The message field is too short or empty!';

if((int)$_POST['captcha'] != $_SESSION['expect'])
   $err[]='The captcha code is wrong!';


if(count($err))
{
   if($_POST['ajax'])
   {
      echo '-1';
   }

   else if($_SERVER['HTTP_REFERER'])
   {
      $_SESSION['errStr'] = implode('<br />',$err);
      $_SESSION['post']=$_POST;
      
      header('Location: '.$_SERVER['HTTP_REFERER']);
   }

   exit;
}


Then it passes that the "checksum" (either 1 or -1) back to the jquery...

Code:
var use_ajax=true;

           $.validationEngine.settings={};   
      
         $("#contact-form").submit(function(e){
   
         if(use_ajax)
         {
            $("#loading").css("visibility","visible");
            $.post("modules/contactform/submit.php",$(this).serialize()+"&ajax=1",
            
               function(data){
                  if(parseInt(data)==-1)
                     $.validationEngine.buildPrompt("#captcha","* Wrong verification number!","error");
                     
                  else
                  {
                     $("#contact-form").hide("slow").after("<h1>Thank you!</h1>");
                  }
                  
                  $("#loading").css("visibility","hidden");
               }
            
            );
         }


To process the true or false and present a message if false or go through if true.

Where I'm getting lost is the "if(parseInt(data) ==-1". It "should" be receiving a -1 back if I'm entering an incorrect verification number and displaying an error message via the .buildPrompt. (specific to this validator)

So could I instead of building the error message... output the data so that I can echo it out and debug a bit further down to that real issue of why I'm not seeing any error messages?

Another question I have is... can I eliminate the name, email, subject & text error checking since the validator already checks those inputs for data? (I believe the reason they did this was to display messages in a div rather than by the validator flyout)

Also... the way I have this setup is using a head-contactform.php in the addons and all the rest of the files within my "module" folder (kept it in a module for now so that I can test all the form functions etc)

_________________
Money is the measurement of time - Me
"You can all go to hell…I’m going to Texas" -Davy Crockett 
View user's profile Send private message
killing-hours







PostPosted: Fri Nov 12, 2010 4:15 pm Reply with quote

Disregard... Figured it out. (validator wasn't setup correctly for ajax submit)
 
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Sun Nov 14, 2010 4:04 pm Reply with quote

PM me a link to your files.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
killing-hours







PostPosted: Sun Nov 14, 2010 5:00 pm Reply with quote

Sorry about that... had a lot going on at the time and totally forgot I had opened this topic already. Pm on it's way.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> JavaScript

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©