need immediate help with login code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hafsa786
Forum Newbie
Posts: 1
Joined: Thu Dec 19, 2013 3:08 pm

need immediate help with login code

Post 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
!!!
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: need immediate help with login code

Post by Celauran »

What errors are you getting?
uday.strad
Forum Newbie
Posts: 10
Joined: Wed Oct 02, 2013 1:03 am

Re: need immediate help with login code

Post 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' ";
Post Reply