2017-02-14 11:08


  • php
  • mysql

Am creating an ionic application using php, at the beginning I've linked the login form with a mysql database that I've created using wamp as a server and everything works fine! then my boss saids that I have to change it to another database which is on a Microsoft sql server, so I've linked the wamp server with MsSQL and the Connection with database on MSSQl established correctly

but I didn't know how to change the syntaxe on login.php

Here are the old and new cofig.php that works fine

(New config.php)

$serverName = "HAMDI-PC";
$connectionInfo = array ("Database"=>"MAINT","UID"=>"sa","PWD"=>"sql") ;
$conn = sqlsrv_connect( $serverName, $connectionInfo);

(OLD config.php)

$conn = new mysqli("localhost", "root", "", "MAINT");

And here is the (login.php) that works with mysql database

header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");

if(isset($_GET["username"]) && isset($_GET["password"]) ) {
    if( !empty($_GET["username"]) && !($_GET["password"]) ) {


        $query=" SELECT * FROM D_PROTUSERS WHERE PROT_User='$username' AND    PROT_Password ='$password' ";
        $result = $conn->query($query);

        if ($rs=$result->fetch_array()) {
            if($out != "") {$out .="";}
            $out .='{"PROT_User":"'. $rs["PROT_User"] . '",';
            $out .='"PROT_Password":"'. $rs["PROT_Password"] . '"}';

So please I want to know what should I change to make it work at the new database'MSSQl) , I'll be thankful to everyone who will tries to help :*

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享