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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:05:14+00:00 2026-05-30T03:05:14+00:00

I am creating an ajax login and it used to work but for some

  • 0

I am creating an ajax login and it used to work but for some reason now it redirects me to my php login processing page. The code is below and I am using jquery ajax to submit my ajax request. The weird thing is that it apparently isn’t sending the variables because my page doesn’t echo the word ‘success’. Any help would be appreciated and also, would this be secure to use?


Javascript(jQuery);

$('.mainlogin').submit(function() {
    var username = $('#main_username').val();
    var password = $('#main_pword').val();
    $.ajax({
        url: 'log.php',
        type: 'POST',
        data: {
            user: username,
            pass: password
            },
        success: function(response) {
            if (response == 'success') {
                    window.location.reload();
            } else {
                $('.logerror').fadeIn(250);
            }
        }
    });
    return false;
});

PHP;

<?php 
require_once('.conf.php');
$user = mysql_real_escape_string($_POST['user']);
$pass = mysql_real_escape_string($_POST['pass']);
//$remem = mysql_real_escape_string($_POST['remem']);
//$expire=time() + 60 * 60 * 24 * 30;

$result = mysql_query("SELECT * FROM TABLENAME WHERE username = '$user'");
while ($row = mysql_fetch_array($result)) {
if (sha1($user.$pass) == $row['pword']) {
    //setcookie('temp', $row['username']);
    session_start();
    $_SESSION['login'] = 1;
    $_SESSION['uname'] = $row['username'];
    $_SESSION['id'] = $row['id'];
    echo "success";
} 
}
?>

Thanks so much!! I can’t figure this out and have run multiple javascript checks, none of which gave me an error.

  • 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-30T03:05:15+00:00Added an answer on May 30, 2026 at 3:05 am

    Is the login processing page the value of your form’s action attribute? If so it sounds like the form is being submitted instead of your AJAX being called.

    Are you testing in a browser where you can see the response from your PHP script? Chrome/WebKit have a network tab where you can view the response of XHR (Ajax) requests.

    You could try:

    $('.mainlogin').submit(function(e) {
        e.preventDefault();
    

    as your anonymous function definition to prevent the from from being submitted in the standard HTML fashion.

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

Sidebar

Related Questions

I am creating one html login form and sending requests to login.php file. Now
What is the best way to implement a AJAX login portal? I am creating
As I said in another question in here, I'm creating a login class, but
I am creating a complete ajax application where there is one base page and
I am creating a loginform like this: @using (Ajax.BeginForm(Login, new AjaxOptions() { HttpMethod =
I am creating an ajax function to edit some settings. these must be handled
I am trying to adapt Ion auth to work with ajax, because my login
I'm creating an AJAX form. The problem is when I'm trying to create a
I am interested in creating an AJAX form submit in a jQuery overlay. I
I am creating an jquery ajax application.. where i got stuck And i uploaded

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.