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

  • Home
  • SEARCH
  • 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 4587566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:47:56+00:00 2026-05-21T21:47:56+00:00

Alright so I have this function <?php /** * @author Mitchell A. Murphy *

  • 0

Alright so I have this function

<?php

/**
 * @author Mitchell A. Murphy
 * @copyright 2011
 */
include ('func_lib.php');
connect();
echo (check($_POST['input']) ? 'true' : 'false');
function check($args)
{
    $args = strtolower($args);
    $checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
    if (preg_match($checkemail, $args))
    {
        //logic for email argument
        $sql = "SELECT * FROM `users` WHERE `email`='" . $args . "'";
        $res = mysql_query($sql) or die(mysql_error());
        echo "type=email:";
        if (mysql_num_rows($res) > 0)
        {
            return true;
        } else
        {
            return false;
        }
    } else
    {
        //logic for username argument
        $sql = "SELECT * FROM `users` WHERE `username`='" . $args . "'";
        $res = mysql_query($sql) or die(mysql_error());
        echo "type=username:";
        if (mysql_num_rows($res) > 0)
        {
            return true;
        } else
        {
            return false;
        }
    }

}

?>

The function should be accessed by this jquery script:

$('form.register .submit').click(validateRegister);

function validateRegister() {

    //Variables
    var emailExists = false;
    var userExists = false;
    var $error = "";

    //Executes functions
    email();


    function email() {
        var $error = $('#email .error');
        var input = $('#email input').val();
        var emailRE = /^.*@.+\..{2,5}$/;
        if (input.match(emailRE)) {
            $error
                .html('<div>Proper Email Format: <span>Hello@Yoursite.com</span></div>')
                .animate({
                'left': '-130px',
                'opacity': '0'
            });

            //Checks for Existing Email

            function checkExisting_email() {
                $.ajax({
                    type: 'POST',
                    url: 'includes/checkExist.php',
                    data: input,
                    statusCode: {
                        404: function () {
                            alert('page not found');
                        }
                    },

                    success: function (data) {
                        alert(data);
                    },
                    error: function () {
                        alert("error bro");
                    }
                });

            }
            emailExists = checkExisting_email();

            //If it exists
            if (emailExists) {
                alert("This email already exists!");
            } else if (emailExists == false) {
                alert("Email doesnt exist!");
            }

        } else {
            //Email doesn't match
            $error
                .html('<div>Proper Email Format: <span>Hello@Yoursite.com</span></div>')
                .animate({
                'left': '-150px',
                'opacity': '1'
            });
        }
    }
    return false;
}

But for some reason the script (js) isn’t sending any data? if so, how do i reference it. I am the backend developer but the designer who did the javascript left me to fix this. I know the php works because I made a test form to send the data with this html markup:

<form action="includes/checkExist.php" method="post">
<input type="text" name="input" />
<input type="submit" name="submit" />
</form>

And that works…so why is the input from jquery returning as NULL?

  • 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-05-21T21:47:56+00:00Added an answer on May 21, 2026 at 9:47 pm

    See that checkExisting_email() don’t return anything, so emailExists = checkExisting_email(); will not set emailExists. This data will only be provided on the callback function, which today only display the result on an alert().

    To make things easier, use jQuery ajax validation field remote. Check the documentation and sample.

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

Sidebar

Related Questions

Alright so I have this C++ image capturing class. I was wondering if I
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
Alright, currently I have my SWF hitting a php file that will go and
Alright well, I connect to 3 different ip's when I run this script. It
I have written this piece of code here and I have linked it alright
Alright, so I have a base class which we'll call TFruit . From this
Alright I am still learning my functions in php but this particular piece of
So I got this form: <form action=welcome.php method=post> <input type=hidden name=secret value=<?php echo getMyValue()
So I have here a JavaScript stack built after this function: function Stack() //Creating

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.