I've written php script for user login but rather than exhibiting the end result the entire script has been displayed.I've given b .perl file link being an action for that login form.

I'm using xampp with php and mysql running will i need other things?

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");   
    }

?>

There is a couple of errors inside your code, but I'm not sure if they are what exactly are leading to your problems.

First of all inside your CSS user_login ought to be #user_login to choose elements using the ID "user_login". Then, display = inline; ought to be display: inline;.

Inside your PHP...

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

...does not do anything whatsoever. I believe you ought to have

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

So that as Ethan pointed out within the comments above, your quotes are screwed up:

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

...should most likely be:

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

(Escape your quotes inside quotes utilizing a backslash).

Fix individuals errors and find out whether it works then...

Also: as LeleDumbo states above, make certain the page has been loaded through Apache instead of opened up like a file. The URL must start with something similar to 127.0.0.1 or localhost. Otherwise, just put 127.0.0.1 to your address bar and study for your file within the list that seems.


Another error- your SELECT statement must be a string:

$query = mysql_query("SELECT * FROM users WHERE username = '$username'");