can any body help me or give me an sample code on how to create a very simple log in system using php and mssql..tnx in advance.

Member Avatar
diafol

What have YOU done so far. Show your code.

login form

<form name="log" action="log_action.php" method="post">
Username: <input class="form" type="text" name="name"><br />
Password: <input class="form" type="password" name="ssn"><br />
<input name="submit" type="submit" value="Submit">
</form>

log_action

<?php
session_start();
include "ms_connection.php";
$name = $_REQUEST['name'];
$ssn  = $_REQUEST['ssn'];
$query = "SELECT * FROM userinfo WHERE name = '$name' AND ssn='$ssn'";
$result = mssql_query($query,$conn);
$num = mssql_num_rows($result);
$_SESSION['valid_user'] = true;
$_SESSION['name'] = $name;
header('Location: index.php'); 
die(); 
}else{
header('Location: login1.php');
die();
}

ms_connection

<?php
$serverName = "server"; 
$uid = "uname";   
$pwd = "upassword";  
$databaseName = "dtr"; 
$connectionInfo = array( "UID"=>$uid,                            
                         "PWD"=>$pwd,                            
                         "Database"=>$databaseName); 
/* Connect using SQL Server Authentication. */  
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>
Member Avatar
diafol

Why are you interchanging sqlsrv and mssql ?

I don't use SQL Server, but I thought that mssql was old although worked on both Windows and Linux and that sqlsrv was the official MS driver, but only worked on Windows (I may be wrong).

yes your correct but the device i used is using a built in database which is mssql..bu i cant correctly developed a log in system with a mssql

Download and use Webmatrix it has a few template starter sites.