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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:57:49+00:00 2026-05-28T07:57:49+00:00

I have written php script for user login but instead of displaying the result

  • 0

I have written php script for user login but instead of displaying the result the whole script is being displayed.I have given a .php file link as an action for the login form.

I am using xampp with php and mysql running do I need anything else?

the code is :

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />

  <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame 
       Remove this if you use the .htaccess -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

  <title>Ch</title>
  <meta name="description" content="education,India,College search in india,score evaluator" />
  <meta name="author" content="RAJATEJAS" />
  <meta name="viewport" content="width=device-width; initial-scale=1.0" />

  <!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
  <link rel="shortcut icon" href="/favicon.ico" />
  <link rel="apple-touch-icon" href="/apple-touch-icon.png" />

  <style type = "text/css">
    user_login , input
    {
        display = inline;   
    }   
  </style>

</head>

<body>
  <div>
    <header>
      <h1>Ch</h1>
    </header>

    <nav>
      <p><a href="/">Home</a></p>
      <p><a href="/contact">Contact</a></p>
    </nav>

    <div class = "user_login_form">
        <form action = "chalo_login.php" method="post">
            <label>Username:</label><input id = "username" type = "text" name = "username" autofocus placeholder="Enter Username"/><br />
            <label>Password:</label><input id = "password" type = "password" name = "password" placeholder="Enter Password"/><br />
            <input name = "submit" type = "submit" value = "Login" />
        </form>   
    </div>


    <footer>
     <p>&copy; Copyright  by RAJATEJAS</p>
    </footer>
  </div>
</body>
</html>

<?php
    session_start();
    $_POST['username'];
    $_POST['password'];

    if ($username&&$password)
    {
        $connect = mysql_connect("localhost","root","");
        mysql_select_db("phplogin") or die("could not find database");
        $query = mysql_query(SELECT * FROM users WHERE username = "$username");
        $numrow = mysql_num_rows($query);
        if ($numrows !=0)
        {
            while ($row = mysql_fetch_assoc($query))
            {
                $dbusername = $row["username"];
                $dbpassword = $row["password"];
            }
            if($username == $dbusername && $password == $dbpassword)
            {
                echo "You are logged in! ;
                <a href ="member.php">Click here</a>";
                $_SESSION["username"] = $dbusername;

            }
            else
            {
                echo "Incorrect password";
            }
        }else{die("Account does not exists");}
    } 
    else 
    {
    die ("Please enter details");   
    }

?>
  • 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-28T07:57:50+00:00Added an answer on May 28, 2026 at 7:57 am

    You’ve got a few errors in your code, but I don’t know if they’re what are causing your problems.

    Firstly in your CSS user_login should be #user_login to select elements with the ID “user_login”. Then, display = inline; should be display: inline;.

    In your PHP…

    $_POST['username'];
    $_POST['password'];
    

    …doesn’t do anything. I think you should have

    $username = $_POST['username'];
    $password = $_POST['password'];
    

    And as Ethan mentioned in the comments above, your quotation marks are messed up:

    echo "You are logged in! ;
    <a href ="member.php">Click here</a>";
    

    …should probably be:

    echo "You are logged in! <a href =\"member.php\">Click here</a>";
    

    (Escape your quotation marks inside quotation marks using a backslash).

    Fix those errors and see if it works then…

    Also: as LeleDumbo says above, make sure the page is being loaded through Apache rather than opened as a file. The URL should begin with something like 127.0.0.1 or localhost. If not, just put 127.0.0.1 into your address bar and browse to your file in the list that appears.


    Another error- your SELECT statement needs to be a string:

    $query = mysql_query("SELECT * FROM users WHERE username = '$username'");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simplte PHP login script which starts a session: //Lets start
So I have a script (written in PHP) that posts the user input of
So I have a script (written in PHP) that posts the user input of
I have written a script image.php that is quite long, but I've just copied
I have written a very very very simple!! script in php. header redirection not
I have a written a script in PHP that reads from data from a
I have written a PHP script that checks whether a domain is available for
I have a search script written in jQuery. To submit a query a user
I have a Google Instant style search script written in jQuery. When the user
I have a Google Instant style search script written in jQuery. When a user

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.