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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:19:57+00:00 2026-06-03T11:19:57+00:00

I am developing login form In PHP The form is as follows <form method=post

  • 0

I am developing login form In PHP
The form is as follows

<form method="post" action="Login.php" id="Log">
<select id="Login" name="Type">
<option value="Sel" selected="selected">Select Login type</option>
<option value="Student">Student</option>
<option value="Faculity">Faculity</option>
</select>
<div id="type">
<p id="Ch">Group Id: &nbsp;<input id="l" name="log" type="text"/></p>
<p id="Pass">Password: &nbsp; <input id="p" name="Pass" type="password" /></p>
<input id="Cond" type="Text" />
<input type="submit" value="Login"  />
<p id="Invalid" style="padding-top:.75em; color:#FF0000;">Invalid Login Or Password</p>
</form>

In post.php I connect with database and check login and passwords.

I want to show the <p id="invalid"> tag when password or login don’t match in the same form below it without any delay.

The <p id="invalid"> is hidden at the beginning and only be shown when login or pasword is incorrect

How can I achieve this/ connect with database through PHP?

  • 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-03T11:20:09+00:00Added an answer on June 3, 2026 at 11:20 am

    I agree with Galen’s answer. You should put the login procession stuff on the same page. If you don’t know how to do that, you should do this:

    <?php
    $itswrong = false;
    if (isset($_POST['Pass']) && isset($_POST['log'])) {
    $sql = 'SELECT * FROM your_database_name WHERE group_id = '{$_POST['log']}' AND password = SHA1('{$_POST['Pass']}')";
    $result = @mysql_query($sql) or die (mysql_error());
    if (mysql_num_rows($result) == 1) {
    // Match was found!
    // Do whatever here, e.g. session registering (starting a session), etc.
    } else {
    // Oh damn, it's wrong!
    $itswrong = true;
    // Do stuff here
    }
    } else {
    // Move your form in here
    }
    ?>
    

    All you need to do in your form is move it to under // Move your form in here, change
    this:

    <p id="Invalid" style="padding-top:.75em; color:#FF0000;">Invalid Login Or Password</p>
    

    to this:

    <?php
    if (isset($_POST['Pass']) && isset($_POST['log']) && $itswrong == true) {
    ?>
    <p id="Invalid" style="padding-top:.75em; color:#FF0000;">Invalid Login Or Password</p>
    <?php
    }
    ?>
    

    and also change the values in the SQL query to suit your needs. Then it would work. I want you to move the form under // Move your form in here, because then if the form is not submitted, it will show.

    EDIT: Also change the title of your form,

    From this:

    <form method="post" action="Login.php" id="Log">
    

    To this:

    <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="Log">
    

    That will make the page just post the data to itself, making my code on top possible.

    I do not suggest ajax, as it is WAY harder for hackers to hack into PHP then JavaScript-related technology, as JavaScript is client-side and PHP is server-side.

    Please notify me if you still have problems.

    Lucas

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

Sidebar

Related Questions

I am developing a login form with User Name and Password. I want the
I'm developing an iPhone application where I wish to authenticate (login form) on a
i am developing in JSF a Spring Security application. the login form is fine.
I am developing an application in which I am using a login form at
Hi I'm starting with android developing, and I have to create a login form
Hi I'm starting with android developing, and I have to create a login form
I am currently developing a C# Windows Form Application. After the user has login
I'am developing a module for Drupal which provides a login form and after submission
I am developing a facebook app using PHP. I am able to login using
I'm developing a simple login form with JSF, Jboss and Oracle. The problem 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.