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">
  <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" />

  <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;   



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

    <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" />

     <p>&copy; Copyright  by RAJATEJAS</p>


    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;

                echo "Incorrect password";
        }else{die("Account does not exists");}
    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...


...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 or localhost. Otherwise, just put 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'");