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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:55:37+00:00 2026-05-20T16:55:37+00:00

i have a simple form to validate if an user exists in the db,

  • 0

i have a simple form to validate if an user exists in the db, and permit the login to another page (yes i remove the password validation to simplify the code, and i test without pass and the script always show Your login is not valid).

Database: emprego, table: users, fields: id, username, email, pass

<script type="text/javascript" language="javascript">
$(document).ready(function () {
    $("#login_form").submit(function () {
        $("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
        $.post("ajax_login.php", {
            name: $('#name').val(),
        }, function (data) {
            if (data == 'yes') {
                $("#msgbox").fadeTo(200, 0.1, function () {
                    $(this).html('Logging in.....').addClass('messageboxok').fadeTo(900, 1, function () {
                        document.location = 'secure.php';
                    });
                });
            } else {
                $("#msgbox").fadeTo(200, 0.1, function () {
                    $(this).html('Your login is not valid').addClass('messageboxerror').fadeTo(900, 1);
                });
            }
        });
        return false; 
    });
}); 
</script>
    </head>
    <body>
        <form method="post" action="" id="login_form">
                    User Name : <input name="name" type="text" id="name">
                <div class="buttondiv">
                    <input name="Submit" type="submit" id="submit" value="Login" style="margin-left:-10px; height:23px">
                    <span id="msgbox" style="display:none"></span>
                </div>
        </form>

file: ajax_login.php

<?php 

include("includes/f_banco.php");
conecta ();


$check = mysql_query("SELECT username FROM users WHERE username ='".mysql_real_escape_string($_POST['name'])."'")or die(mysql_error());
$row=mysql_fetch_array($check);

if ($row['username'] == $_POST['name']) {
    echo "yes";
    $_SESSION['name']=$row['username'];
}else{echo "no";}

?>

EDIT: updated code

what is the possible cause?

  • 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-20T16:55:37+00:00Added an answer on May 20, 2026 at 4:55 pm

    i see lots of problems

    <?php  
    //removed the # from the post
    $name = mysql_real_escape_string($_POST['name']);
    //whys this here?
    $row=mysql_fetch_array($check);
    //name cant be used (common mistake)
    $check = mysql_query("SELECT name FROM users WHERE name ='".$name."'")or die(mysql_error());
    $check2 = mysql_num_rows($check);
    if ($check2 == 1) {
        echo "yes";
        $_SESSION['name']=$name;
    }
    
    else
    echo "no";
    ?>
    

    try something like this

    <?php  
    session_start();
    include("includes/f_banco.php");
    conecta ();
    
    if(isset($_SESSION['name'])){echo "yes";}else{
        $check = mysql_query("SELECT username FROM users WHERE username ='".mysql_real_escape_string($_POST['name'])."' LIMIT 1")or die(mysql_error());
        $row=mysql_fetch_array($check);
    
        if ($row['username'] == $_POST['name']) {
            echo "yes";
            $_SESSION['name']=$row['username'];
        }else{echo "no";}
    }
    
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form on a view page, implemented as a user control,
There are some HTML based games (ie bootleggers.us) that have a simple login form
I have a simple form that I would like to validate on form submission.
I have a login.jsp page which contains a login form. Once logged in the
I have a simple form with some plain html input like bellow using ASP.NET
Say I have this simple form: class ContactForm(forms.Form): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True)
I'm making my first foray into WPF - I have a simple form with
We have a simple registration form for our website users where we only require
I have a relatively simple form which asks a variety of questions. One of
Ok, so I have a very simple form with next to no logic in

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.