Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7961503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:03:21+00:00 2026-06-04T05:03:21+00:00

I have a function that I’m calling that validates a recaptcha, and then depending

  • 0

I have a function that I’m calling that validates a recaptcha, and then depending on whether that validates successfully, sends out an email. I am validating the recaptcha using a jquery .ajax function, and upon successful validation uses another jquery .ajax function to send the email.

Here is the javascript:

function validateCaptcha(){
var isValid = $('#es_contact_form').valid();
var esform = $('#es_contact_form').serialize();
var html = $.ajax({
type: "POST",
url: "scripts/ajax.recaptcha.php",
data: esform,
async: false
}).responseText;

if(isValid)
{
   if(html == "success")
   {
        //alert("Captcha and form are valid");
    //return true;
    var esform2 = $('#es_contact_form').serialize();
    var response = $.ajax({
    type: "POST",
    url: "scripts/ajax.email.php",
    data: esform2,
    async: false
    }).responseText2;
    if(response=="success")
    {
    alert('mail successfully sent');
                    return true;
                }else{
                    alert('mail not sent, please try again');
                    Recaptcha.reload();
                    return false;
                }
            }
            else
            {
                alert('Form valid, captcha bogus');
                $("#captchaStatus").html("Your captcha is incorrect. Please try again");
                Recaptcha.reload();
                return false;
            }
        }else{
            if(html == "success")
            {
                //alert("Captcha's good, but the form aint!");
                Recaptcha.reload();
                return false;
            }
            else
            {
                //alert('Form invalid, captcha bogus...can you do anything right?');
                $("#captchaStatus").html("Your captcha is incorrect. Please try again");
                Recaptcha.reload();
                return false;
            }
        }
    }

Here is the serverside code for the script where I am getting the 500 server error:

<?php

$yourName = 'ES';
$yourEmail = 'rob@domain.com';
$yourSubject = 'ES: contact form';
$referringPage = 'es.domain.com';



function cleanPosUrl ($str) {
$nStr = $str;
$nStr = str_replace("**am**","&",$nStr);
$nStr = str_replace("**pl**","+",$nStr);
$nStr = str_replace("**eq**","=",$nStr);
return stripslashes($nStr);
}
if ( isset($_POST) ) {
$to = $yourEmail;
$subject = $yourSubject;
$message = cleanPosUrl($_POST['name'])."\r\n\n";
$message .= cleanPosUrl($_POST['remail'])."\r\n\n";
$message .= cleanPosUrl($_POST['phone'])."\r\n\n";
$message .= cleanPosUrl($_POST['comments']);
$headers = "From: ".cleanPosUrl($_POST['name'])." <".cleanPosUrl($_POST['remail']).">\r\n";
$headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n";
$mailit = mail($to,$subject,$message,$headers);
}

    if ( $mailit )
    { ?>success<? }
    else
    { die ("The mail wasn't sent"); }
}
?>

Both ajax.recaptcha.php and ajax.email.php pull from the post and then return “success” if they are successful.

The ajax.recaptcha.php is working fine. But when it gets to the ajax.email.php script, I keep getting a 500 server error in Firebug.

Does anyone have a clue as to why one would work and not the other? The scripts are both in the same folder on the same server, so I can’t see why this isn’t working.

Any help is greatly appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:03:22+00:00Added an answer on June 4, 2026 at 5:03 am

    There’s an extra } in the code.. you should get rid of } right after

    $mailit = mail($to,$subject,$message,$headers);
    

    I completely agree with jugnu, For better debugging in such case you should try using static values to send email. (instead of POST[]).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that accepts a class (not an instance) and, depending on
I have a function that is recursively calling itself, and i want to detect
I have a function that calls out a read or write request on a
I have a function that exports a table into a CSV file, then I
So I have function that formats a date to coerce to given enum DateType{CURRENT,
In my Java code I have function that gets file from the client in
I have function Start() that is fired on ready. When I click on .ExampleClick
I have a function that is being called from different threads in the application.
I have a function that allows users to edit a row in a table
I have a function that pulls rows from a database, the content->id and content->type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.