Page 1 of 1

need immediate help with login code

Posted: Thu Dec 19, 2013 3:11 pm
by hafsa786
i havethis login code which is not working,I m new to php
login.php:

Code: Select all

<?php 

include("sqltestlocal.php"); //including config.php in our file
$username = $_POST['username']; //Storing username in $username variable.
$password = $_POST['password']; //Storing password in $password variable.


$match = "select * from tbllogin where username = '".$username."' and password = '".$password."'";

$qry = sqlsrv_query($match);

$row_count = sqlsrv_num_rows($qry); 

if ($row_count == 1) { 
 $row = sqlsrv_fetch_array($qry); 
 
        session_start(); 
       
        $_SESSION['firstname'] = $row['firstname']; 
       
        $_SESSION['logged'] = TRUE; 
        header("Location: test1.html"); // Modify to go to the page you would like
         exit; 
login.php:

//echo $row_count;
//echo $username;
//echo $password;

//echo "Try notagainnnnnnnnnnnnn";

//sqlsrv_free_stmt($conn,$qry);

//exit; 

} else {
 

header("iisstart.html");
exit;
// It is the page where you want to redirect user after login.
}

?>
form contains the username field and password field
and sql server connection is also working ,its just the login not working
!!!

Re: need immediate help with login code

Posted: Thu Dec 19, 2013 8:01 pm
by Celauran
What errors are you getting?

Re: need immediate help with login code

Posted: Mon Jan 06, 2014 4:54 am
by uday.strad
Its better you show us the errors ....
Also Try this... if it works...
may b the inverted comas are a problem....

$match = "select * from tbllogin where username = '$username' and password = '$password' ";