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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:16:10+00:00 2026-05-28T17:16:10+00:00

I have a login form using jquery ajax and a php code. The issue

  • 0

I have a login form using jquery ajax and a php code. The issue is that is always returns an error instead of logging me into the system. I have spent days trying to find the error but I can’t. The webpage displays no errors if I visit it directly. This used to work about a week ago until I accidentally deleted the jquery and now I can’t get it to work.

Here is the PHP code:

include('.conf.php');
$user = $_POST['user'];
$pass = $_POST['pass'];
$result = mysql_query("SELECT * FROM accountController 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'];
        echo "success";
    }
} 

and here is the Jquery AJAX code:

var username = $('#main_username').val();
var password = $('#main_pword').val();
    $('.mainlogin').submit(function() {
        $.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;
    });

How would I check to see what is being returned like blank or success from the server. Is there any extension for safari? 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-05-28T17:16:11+00:00Added an answer on May 28, 2026 at 5:16 pm

    Put this in, instead. It will alert the server’s response in a popup.

     success: function(response) {
         alert(response);
     }
    

    On your PHP side, try outputting more stuff – add an }else{ to your if statement that returns some useful data, for example

     }else{
        print("Post is: \n");
        print_r($_POST);
        print("\nMySQL gave me: \n");
        print_r($row); 
     }
    

    Just make sure you don’t leave it in once it’s working!

    Look for:

    • hash is different
    • db field is different
    • db fields are blank for some reason
    • POST data is wrong / wrong field names

    Edit: Here’s another issue: Your first four lines should actually be:

        $('.mainlogin').submit(function() {
            var username = $('#main_username').val();
            var password = $('#main_pword').val();
            $.ajax({
    

    Your code as it is gets the values before the form is submitted – at load – when they are blank, and as a result is sending blank strings to the server as username and password.

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

Sidebar

Related Questions

I have successfully built a login form using ajax and want to add a
Ok, so I have a Login form and I'm using Jquery to display it
I have a simple login form that captures username/password with some simple Javascript (JQuery)
I have a form in a jQuery tab div that is loaded with AJAX:
I have a jQuery login form that uses $post function to send credentials to
I'm using asp.net mvc 3 with unobtrusive jquery validation. I have a form that
I have a login form that has Username and password as inputs from user
There are some HTML based games (ie bootleggers.us) that have a simple login form
I have just started PHP and MySQL and have created a login form and
I would like to have a simple login form (or any form for that

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.