0

Guys please help.. It always says "Sorry, cannot log you in. Wrong login information". Thank u..

<?php
        session_start();
        include "dbConfig.php";

        if ($_GET["op"] == "login")
  {
  if (!$_POST["StudentID"] || !$_POST["password"])
        {
        die("You need to provide a username and password.");
        }
  $q = "SELECT * FROM `student` "
        ."WHERE `StudentID`='".$_POST["StudentID"]."' "
        ."AND `password`=password('".$_POST["password"]."') "
        ."LIMIT 1";
  $r = mysql_query($q);
  if ( $obj = @mysql_fetch_object($r) )
        {
        // Login good, create session variables
        $_SESSION["FullName"] = $obj->FullName;
        $_SESSION["valid_user"] = $_POST["StudentID"];
       //$_SESSION["valid_time"] = time();
        Header("Location: Main.php");
        }
  else
        {   
        die("Sorry, could not log you in. Wrong login information.");
        }
  }
        else
  {
  echo "<form action=\"?op=login\" method=\"POST\">";
  echo "Username: <input name=\"StudentID\" size=\"15\"><br />";
  echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />";
  echo "<input type=\"submit\" value=\"Login\">";
  echo "</form>";
  }
 ?>
3
Contributors
6
Replies
8
Views
4 Years
Discussion Span
Last Post by NardCake
0

Apparently, your query does not return any results. Are you sure you entered the right combination, and you inserted the password correctly in the first place?

0

There is still an error sir..

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"
        ."WHERE `username`='".$_POST["username"]."' "
        ."AND `passwor' at line 1 
0

Sir, I edited the query..I used this

SELECT * FROM `register` 
        WHERE `username`='".$_POST["username"]."' 
        AND `password`='".$_POST["password"]."' 
        LIMIT 1

But now the error is "Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\jan\Index.php:6) in C:\xampp\htdocs\jan\Index.php on line ***"

0

In my queries I never use username='"'.$value.'"' I always go

username='$username'

try that, works for me!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.