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 9037993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:22:43+00:00 2026-06-16T09:22:43+00:00

I’m trying to code a login script using the following: A Jquery snippet :

  • 0

I’m trying to code a login script using the following:

A Jquery snippet:

<script type="text/javascript">
$(function(){

$('div#login-button').click(function(){
            var email = $("#login_email").val();
            var password = $("#login_password").val();
            $.post("functions/login.php?email="+email+"&password="+password, {
            }, function(response){
                if($(response).html() == "correct")
                    window.location.href = "home.php";
                else window.alert($(response).html());
            });
});

});
</script>

HTML code:

<div id="login-type-1">
            E-mail:<input type="text" id="login_email" name="email" value="Type your Email ID" class="input" maxlength="100"/><br />
            Password:<input type="password" id="login_password" name="password" value="password" class="input" maxlength="30"/>
        <a href="#"><div id="login-button"><span>Log in</span></div></a>
</div>

functions/login.php:

<?php
    require_once('db.php');

        session_start();

        $email = $_REQUEST['email'];
        $password = $_REQUEST['password'];

        if(!$email || $email == "Type your Email ID")
            echo "<p>Please input your email id.</p>";
        if(!$password)
            echo "<p>Please input your password.</p>";

        if($email && $password && $email != "Type your Email ID"){
            $check = mysql_query("SELECT u_id, u_fname, u_lname, u_email FROM user_data WHERE u_password = '".md5($password)."' AND u_email = '".$email."'");
            $result = mysql_num_rows($check);
            if ($result == 1){

                $row = mysql_fetch_assoc($check);

                $_SESSION['u_id'] = $row['u_id'];
                $_SESSION['u_fname'] = $row['u_fname'];
                $_SESSION['u_lname'] = $row['u_lname'];
                $_SESSION['u_email'] = $row['u_email'];
                $_SESSION['u_name'] = $row['u_fname']." ".$row['u_lname'];

                echo "<p>correct</p>";

            }
            else {
                echo "<p>Invalid Authentication</p>";
            }
        }
?>

Database connection:

class db {
    public static $hostname_adminconn = "localhost";
    public static $database_adminconn = "masterdb";
    public static $username_adminconn = "root";
    public static $password_adminconn = "qwerty";
    public static $adminconn;

    public static function dbDb() {
        return db::$database_adminconn;
    }
    public static function dbConn() {
        return db::$adminconn;
    }
}
db::$adminconn = mysql_connect(db::$hostname_adminconn, db::$username_adminconn, db::$password_adminconn) or trigger_error(mysql_error(),E_USER_ERROR);

Still, I’m unable to login. Could someone help me in debugging it?

  • 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-16T09:22:45+00:00Added an answer on June 16, 2026 at 9:22 am

    Your PHP returns this:

    echo "<p>correct</p>";
    

    But JavaScript checks for this:

    if($(response).html() == "correct")
    

    That comparison will not work.

    Having said that, you should return a more suitable response type, such as JSON:

    header('Content-Type: application/json');
    
    echo json_encode(array(
        'res' => 'ok',
    ));
    

    In your JavaScript:

    if (response.res === 'ok') {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am reading a book about Javascript and jQuery and using one of the
Basically, what I'm trying to create is a page of div tags, each has
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is

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.