hi i created login page using php and mssql but i got an error
"Fatal error: Call to undefined function mssql_query() "

heres my log in code

<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_in form

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

Do you have your PHP extensions configured correctly? Also I am not sure what version of PHP version you are using or your OS, but PHP support for MSSQL is not supported on windows with PHP 5.3 or later.
http://www.php.net/manual/en/intro.mssql.php

my version of php is php5.3.13
and i already configured "extension=php_pdo_sqlsrv_53_ts.dll and extension=php_sqlsrv_53_ts.dll" php extensions in php.ini

As I understand it, you need to use the ODBC driver to connect PHP to mssql. I may be a bit behind on that info, but I would be curious to see if you are connecting at all.

can anybody give a a sample code on how to use ODBC driver to connect php to mssql?

hi,

here is a similar question about mssql. I did not evaluate any of the claims, but it appears to be promising.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.