-3

I am making this code to work on sql server but i am not sure how to go about it i have changed all of the MySQL commands to mssql but i am not sure what else needs to be changed am i missing a dll or something as i am getting error messages like this:

Fatal error: Call to undefined function mssql_connect() in on line 8 Call Stack: 0.0012 353392 1. {main}()login.php:0

Here is the code i have changed username and password for obvious reasons,

<?php
    session_start();

    $username = $_POST['txt_username'];
    $password = $_POST['txt_password'];
if ($username&&$password){  

    $connect = mssql_connect("server", "username", "password") or die("No Server Found");

    mssql_select_db("database name") or die("No Connection");

    $query = mssql_query("SELECT * FROM account WHERE username='$username'");
    $numrows = mssql_num_rows($query); 

    if($numrows !=0){
        while ($rows = mssql_fetch_assoc($query)){

            $dbusername = $row['username'];
            $dbpassword = $row['password'];
            }
     if ($username == $dbusername && $password == dbpassword) {

         echo "Login Successful. <a href='homepage.php'></a>";

         $_SESSION['username'] = $dbusername;

             } elseif ($username == '' || $password == '') {

             die("Please enter a username and password");

                 } elseif (empty($dbusername)) {

                     die("This account does not exsist");

                     } else {
                           die("Please enter a username and password");
                            }
                }

}?>
Tony Stark
  • 8,064
  • 8
  • 44
  • 63
Tasty
  • 5
  • 1
  • 2

2 Answers2

0

Use PDO, myssql are deprecated, take a look here:

mssql_connect no longer working as of PHP 5.3

and here

http://www.php.net/manual/en/ref.pdo-sqlsrv.php

Community
  • 1
  • 1
Guerra
  • 2,792
  • 1
  • 22
  • 32
0

Create this page:

<?php
  php_info()
?>

Then accessing that page will tell you everything you want to know about how your PHP environment is set up. I suspect that you don't have the mssql module enabled.

Robert McKee
  • 21,305
  • 1
  • 43
  • 57