0

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.

7
Contributors
9
Replies
69
Views
3 Years
Discussion Span
Last Post by MikeJones_1
0

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));
}
?>
0

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).

0

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

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.