<form action="page.php" method="POST">
<div class="col text-center" style="border: 0px solid blue;">
....
<?php
include 'start0.php';
$serverName = "1????,59365";
$connectionInfo = array( "WIN-APIUFD1NJEU"=>"SS2012EXPR");
$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));
}
error_reporting(E_ALL);
$serverName = "1????,59365";
$connectionInfo = array( "WIN-APIUFD1NJEU"=>"SS2012EXPR");
$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));
}
else{
echo "Connection could not be established.<br />";
file_put_contents('test_error.log', 'Connection could not be established ' . print_r(sqlsrv_errors(), true));
die( print_r( sqlsrv_errors(), true));
}
Then check to see if the file test_error.log is created in the folder of the primary script called.
<?php
include 'start0.php';
error_reporting(E_ALL);
$serverName = "1????,59365";
$connectionInfo = array( "WIN-APIUFD1NJEU"=>"SS2012EXPR");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}
else
{
echo "Connection could not be established.<br />";
file_put_contents('test_error.log', 'Connection could not be established ' . print_r(sqlsrv_errors(), true));
die( print_r( sqlsrv_errors(), true));
}
?>
There is no other issue on page but I have got no message and test_error.log is not created.
<?php
file_put_contents('debug.log', date('Y-m-d H:i:s') . ": Application start ...\n");
include 'start0.php';
error_reporting(E_ALL);
$serverName = "1????,59365";
file_put_contents('debug.log', "\tAttempting connection ...\n", FILE_APPEND);
$connectionInfo = array( "WIN-APIUFD1NJEU"=>"SS2012EXPR");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
file_put_contents('debug.log', "\tConnection established...\n", FILE_APPEND);
}
else
{
echo "Connection could not be established.<br />";
file_put_contents('debug.log', "\tConnection Failed...\n" . print_r(slsrv_errors(), true), FILE_APPEND);
die( print_r( sqlsrv_errors(), true));
}
<body onload="event0()">
<div class="container" style="background:url('./pict/ID-10028343.jpg');border: 0px solid green;background-color: C9D3DD;background-size: cover;background-repeat: no-repeat;width:1200px;height:800px;font-family:Verdana;font-size:14px;">
<form action="page.php" method="POST">
$('#button_id').click(function() {
var data = { }; // any data you need to post to script
$.post('path/to/script.php', data, function(resp) {
// handle response if required;
});
});
to show message when name and password is empty, once Login is clicked.Why do you need a table to check for empty values?
<form>
<input id="username" name="username">
<input type="password" id="password" name="password">
</form>
$(funtion() {
$('form').submit(function(e) {
e.preventDefault();
if (!this.username.value.length || !this.password.value.length) {
alert('Please enter a username and password');
return;
}
data = $(this).serialize();
$.post('validate.php', data, function(resp) {
if (resp.status) {
window.location = resp.url
} else {
alert('Invalid name or password'); // Or whatever error checking you want here
}
}, 'json');
});
});
PHP<?php
$username = isset($_POST['username']) ? $_POST['username'] : false;
$password= isset($_POST['password']? $_POST['password'] : false;
$resp = (object) ['status' => false];
if ($username && $password) {
$resp->status = validateUser($username, $password);
if ($resp->status) {
$resp->url = 'secure.php';
}
}
function validateUser($username, $password) {
// Validate your login here
return true;
}
die(json_encode($resp));
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style>
input {
background-color: F0F08B;
width: 200px;
}
div {
margin: 10px auto;
}
</style>
<script>
function event0() {
var hdr1 = "Logon Page";
document.getElementById("hdr0").innerHTML = hdr1;
}
function clickCancel() {
document.getElementById("username").value = "";
document.getElementById("password").value = "";
//refresh_img();
}
$(funtion() {
$('form').submit(function(e) {
e.preventDefault();
if (!this.username.value.length || !this.password.value.length) {
alert('Please enter a username and password.');
return;
}
data = $(this).serialize();
$.post('validate.php', data, function(resp) {
if (resp.status) {
window.location = resp.url
} else {
alert('Invalid name or password is entered.'); // Or whatever error checking you want here
}
}, 'json');
});
});
</script>
</head>
(index):27 Uncaught SyntaxError: missing ) after argument list
(index):46 Uncaught ReferenceError: event0 is not defined
at onload ((index):46)
$(funtion() ...
Should be$(function() ...
<button type="button" onclick="clickLogin()">Login</button>
to call this?$(function() {
$('form').submit(function(e) {
e.preventDefault();
if (!this.username.value.length || !this.password.value.length) {
alert('Please enter a username and password.');
return;
}
(index):35 Uncaught TypeError: $.post is not a function
at HTMLFormElement.<anonymous> ((index):35)
at HTMLFormElement.dispatch (jquery-3.2.1.slim.min.js:3)
at HTMLFormElement.q.handle (jquery-3.2.1.slim.min.js:3)
<?php
include 'start0.php';
file_put_contents('debug.log', date('Y-m-d H:i:s') . ": Application start ...\n");
error_reporting(E_ALL);
$username = isset($_POST['username']) ? $_POST['username'] : false;
$password= isset($_POST['password']? $_POST['password'] : false;
$resp = (object) ['status' => false];
if ($username && $password) {
$resp->status = validateUser($username, $password);
if ($resp->status) {
$resp->url = 'secure.php';
}
}
function validateUser($username, $password) {
$serverName = "1????,59365";
file_put_contents('debug.log', "\tAttempting connection ...\n", FILE_APPEND);
$uid = "ws_login";
$pwd = "Ws345678";
$databaseName = "house_sch";
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd,
"Database"=>$databaseName);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
die(json_encode($resp));
$tsql = "SELECT user_Name FROM user_master";
/* Execute the query. */
$stmt = sqlsrv_query( $conn, $tsql);
if ( $stmt )
{
echo "Statement executed.<br>\n";
}
else
{
echo "Error in statement execution.\n";
die( print_r( sqlsrv_errors(), true));
}
if( $conn ) {
echo "Connection established.<br />";
file_put_contents('debug.log', "\tConnection established...\n", FILE_APPEND);
}
else
{
echo "Connection could not be established.<br />";
file_put_contents('debug.log', "\tConnection Failed...\n" . print_r(slsrv_errors(), true), FILE_APPEND);
die( print_r( sqlsrv_errors(), true));
}
return true;
}
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style>
input {
background-color: F0F08B;
width: 200px;
}
div {
margin: 10px auto;
}
</style>
<script>
function event0() {
var hdr1 = "Logon Page";
document.getElementById("hdr0").innerHTML = hdr1;
}
function clickCancel() {
document.getElementById("username").value = "";
document.getElementById("password").value = "";
//refresh_img();
}
$(function() {
$('form').submit(function(e) {
e.preventDefault();
if (!this.username.value.length || !this.password.value.length) {
alert('Please enter a username and password.');
return;
}
data = $(this).serialize();
$.post('validate.php', data, function(resp) {
if (resp.status) {
window.location = resp.url
} else {
alert('Invalid name or password is entered.'); // Or whatever error checking you want here
}
}, 'json');
});
});
</script>
</head>
<body onload="event0()">
<div class="container" style="background:url('./pict/ID-10028343.jpg');border: 0px solid green;background-color: C9D3DD;background-size: cover;background-repeat: no-repeat;width:1200px;height:800px;font-family:Verdana;font-size:14px;">
<form action="page.php" method="POST">
<div class="col text-center" style="border: 0px solid blue;">
<header>
<h2><label id="hdr0">hdr1</label></h2>
</header>
</div>
<div class="row" style="border: 0px solid red;">
<div class="col" style="border: 0px solid blue;"></div>
<div class="col text-right" style="border: 0px solid orange;"><b>Username:</b></div>
<div class="col" style="border: 0px solid yellow;"><input type="text" id="username" name="username" style="background-color: white;" /></div>
<div class="col"></div>
<div class="w-100"></div>
<div class="col" style="border: 0px solid blue;"></div>
<div class="col text-right" style="border: 0px solid orange;"><b>Password:</b></div>
<div class="col" style="border: 0px solid yellow;"><input type="password" id="password" name="password" style="background-color: white;" /></div>
<div class="col"></div>
<div class="w-100"></div>
<div class="col" style="border: 0px solid blue;"></div>
<div class="col-md-2" style="border: 0px solid orange;"></div>
<div class="col-md-4" style="border: 0px solid yellow;">
<button type="submit">Login</button>
<button type="button" onclick="clickCancel()">Cancel</button>
</div>
<div class="col"></div>
<div class="w-100"></div>
</div>
</form>
</div>
</body>
</html>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
Do<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
jquery-3.2.1.min.js:4 POST http://113.255.221.200/validate.php 500 (Internal Server Error)Here is validate.php
<?php
include 'start0.php';
file_put_contents('debug.log', date('Y-m-d H:i:s') . ": Application start ...\n");
error_reporting(E_ALL);
$username = isset($_POST['username']) ? $_POST['username'] : false;
$password= isset($_POST['password']? $_POST['password'] : false;
$resp = (object) ['status' => false];
if ($username && $password) {
$resp->status = validateUser($username, $password);
if ($resp->status) {
$resp->url = 'secure.php';
}
}
function validateUser($username, $password) {
$serverName = "1????,59365";
file_put_contents('debug.log', "\tAttempting connection ...\n", FILE_APPEND);
$uid = "ws_login";
$pwd = "Ws345678";
$databaseName = "house_sch";
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd,
"Database"=>$databaseName);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
die(json_encode($resp));
$tsql = "SELECT user_Name FROM user_master";
/* Execute the query. */
$stmt = sqlsrv_query( $conn, $tsql);
if ( $stmt )
{
echo "Statement executed.<br>\n";
}
else
{
echo "Error in statement execution.\n";
die( print_r( sqlsrv_errors(), true));
}
if( $conn ) {
echo "Connection established.<br />";
file_put_contents('debug.log', "\tConnection established...\n", FILE_APPEND);
}
else
{
echo "Connection could not be established.<br />";
file_put_contents('debug.log', "\tConnection Failed...\n" . print_r(slsrv_errors(), true), FILE_APPEND);
die( print_r( sqlsrv_errors(), true));
}
return true;
}
?>
<?php
phpinfo();
Call this and search for the string error_log - that will tell you where the log is and what it is called.
Mar 19 18:06:31 ubuntu1604 PackageKit: get-details transaction /2314_bbdacbec from uid 1001 finished with success after 1161ms
Mar 19 18:06:31 ubuntu1604 gnome-software[3350]: Failed to load snap icon: local snap has no icon
Mar 19 18:06:32 ubuntu1604 gnome-software[3350]: message repeated 4 times: [ Failed to load snap icon: local snap has no icon]
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Activating service name='org.gnome.ControlCenter.Search Provider' requested by ':1.17' (uid=1001 pid=2895 comm="/usr/bin/gnome-shell " label="unconfined")
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Activating service name='org.gnome.Nautilus' requested by ':1.17' (uid=1001 pid=2895 comm="/usr/bin/gnome-shell" label="unconfined")
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Activating service name='org.gnome.Calculator.SearchPro vider' requested by ':1.17' (uid=1001 pid=2895 comm="/usr/bin/gnome-shell " label="unconfined")
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Activating service name='org.gnome.Calendar' requested by ':1.17' (uid=1001 pid=2895 comm="/usr/bin/gnome-shell" label="unconfined")
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Activating service name='org.gnome.seahorse.Application ' requested by ':1.17' (uid=1001 pid=2895 comm="/usr/bin/gnome-shell " label="unconfined")
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Activating via systemd: service name='org.gnome.Terminal' unit='gnome-terminal-server.service' requested by ':1.17' (uid=1001 pid=2895 comm="/usr/bin/gnome-shell " label="unconfined")
Mar 19 18:07:28 ubuntu1604 systemd[2709]: Starting GNOME Terminal Server...
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Successfully activated service 'org.gnome.Calculator.SearchProvider '
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Successfully activated service 'org.gnome.ControlCenter.SearchProvi der'
Mar 19 18:07:28 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Successfully activated service 'org.gnome.Nautilus'
Mar 19 18:07:29 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Successfully activated service 'org.gnome.Calendar'
Mar 19 18:07:29 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Successfully activated service 'org.gnome.seahorse.Application'
Mar 19 18:07:29 ubuntu1604 nautilus[3530]: g_key_file_load_from_file:assertion 'file != NULL' failed
Mar 19 18:07:29 ubuntu1604 nautilus[3530]: Could not establish a connection to Tracker: Failed to load SPARQL backend: Key file does not have group “DomainOntology”
Mar 19 18:07:30 ubuntu1604 dbus-daemon[2735]: [session uid=1001 pid=2735] Successfully activated service 'org.gnome.Terminal'
Mar 19 18:07:30 ubuntu1604 systemd[2709]: Started GNOME Terminal Server.
Mar 19 18:07:30 ubuntu1604 nautilus[3530]: g_queue_pop_head: assertion 'queue != NULL' failed
Mar 19 18:07:34 ubuntu1604 PackageKit: resolve transaction /2315_ddbcecee from uid 1001 finished with success after 2740ms
Mar 19 18:07:35 ubuntu1604 nautilus[3530]: g_queue_foreach: assertion 'queue != NULL' failed
Mar 19 18:07:35 ubuntu1604 nautilus[3530]: g_queue_free: assertion 'queue != NULL' failed
Mar 19 18:07:52 ubuntu1604 org.gnome.Shell.desktop[2895]: polkit-agent-helper-1: pam_authenticate failed: Authentication failure
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] AppArmor D-Bus mediation is enabled
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Activating service name='org.freedesktop.portal.Desktop ' requested by ':1.0' (uid=0 pid=3669 comm="/usr/bin/gnome-syste m-log " label="unconfined")
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Activating service name='org.freedesktop.portal.Documen ts' requested by ':1.1' (uid=0 pid=3692 comm="/usr/libexec/xdg-des ktop-porta l " label="unconfined")
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Activating service name='org.freedesktop.impl.portal.Pe rmissionSt ore' requested by ':1.2' (uid=0 pid=3697 comm="/usr/libexec/xdg-doc ument-port al " label="unconfined")
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Successfully activated service 'org.freedesktop.impl.portal.Permiss ionStore'
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Successfully activated service 'org.freedesktop.portal.Documents'
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Activating service name='org.freedesktop.impl.portal.de sktop.gtk' requested by ':1.1' (uid=0 pid=3692 comm="/usr/libexec/xdg-des ktop-porta l " label="unconfined")
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Activating service name='org.gtk.vfs.Daemon' requested by ':1.4' (uid=0 pid=3712 comm="/usr/libexec/xdg-desktop-porta l-gtk " label="unconfined")
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Successfully activated service 'org.gtk.vfs.Daemon'
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Successfully activated service 'org.freedesktop.impl.portal.desktop .gtk'
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Successfully activated service 'org.freedesktop.portal.Desktop'
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: g_action_print_detailed_name: assertion 'g_action_name_is_valid (action_name)' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: gtk_application_set_accels_for_actio n: assertion 'detailed_action_name != NULL' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: g_action_print_detailed_name: assertion 'g_action_name_is_valid (action_name)' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: gtk_application_set_accels_for_actio n: assertion 'detailed_action_name != NULL' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: g_action_print_detailed_name: assertion 'g_action_name_is_valid (action_name)' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: gtk_application_set_accels_for_actio n: assertion 'detailed_action_name != NULL' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: g_action_print_detailed_name: assertion 'g_action_name_is_valid (action_name)' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: gtk_application_set_accels_for_actio n: assertion 'detailed_action_name != NULL' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: g_action_print_detailed_name: assertion 'g_action_name_is_valid (action_name)' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: gtk_application_set_accels_for_actio n: assertion 'detailed_action_name != NULL' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: g_action_print_detailed_name: assertion 'g_action_name_is_valid (action_name)' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: gtk_application_set_accels_for_actio n: assertion 'detailed_action_name != NULL' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: g_action_print_detailed_name: assertion 'g_action_name_is_valid (action_name)' failed
Mar 19 18:08:00 ubuntu1604 gnome-system-lo[3669]: gtk_application_set_accels_for_actio n: assertion 'detailed_action_name != NULL' failed
Mar 19 18:08:00 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Activating service name='ca.desrt.dconf' requested by ':1.0' (uid=0 pid=3669 comm="/usr/bin/gnome-system-log " label="unconfined")
Mar 19 18:08:01 ubuntu1604 dbus-daemon[3689]: [session uid=0 pid=3687] Successfully activated service 'ca.desrt.dconf'
Mar 19 18:09:01 ubuntu1604 CRON[3748]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean;fi)
Mar 19 18:09:22 ubuntu1604 systemd[1]: Starting Clean php session files...
Mar 19 18:09:22 ubuntu1604 systemd[1]: Started Clean php session files.
Mar 19 18:10:02 ubuntu1604 dhclient[1828]: DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 3 (xid=0x87ab9d6f)
Mar 19 18:10:05 ubuntu1604 dhclient[1828]: DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 6 (xid=0x87ab9d6f)
Mar 19 18:10:09 ubuntu1604 rtkit-daemon[2046]: Supervising 3 threads of 1 processes of 1 users.
Mar 19 18:10:09 ubuntu1604 rtkit-daemon[2046]: message repeated 3 times: [ Supervising 3 threads of 1 processes of 1 users.]
Mar 19 18:10:09 ubuntu1604 rtkit-daemon[2046]: Successfully made thread 3898 of process 3829 (n/a) owned by '1001' RT at priority 10.
Mar 19 18:10:09 ubuntu1604 rtkit-daemon[2046]: Supervising 4 threads of 2 processes of 1 users.
Mar 19 18:10:10 ubuntu1604 rtkit-daemon[2046]: message repeated 2 times: [ Supervising 4 threads of 2 processes of 1 users.]
[Fri Mar 20 20:53:25.037414 2020] [php7:warn] [pid 1780] [client 113.255.208.74:49893] PHP Warning: file_put_contents(debug.loHere is validate.php:g): failed to open stream: Permission denied in /var/www/html/validate.php on line 3, referer: http://113.255.248.189/
[Fri Mar 20 20:53:25.038741 2020] [php7:warn] [pid 1780] [client 113.255.208.74:49893] PHP Warning: file_put_contents(debug.log): failed to open stream: Permission denied in /var/www/html/validate.php on line 16, referer: http://113.255.248.189/
[Fri Mar 20 20:53:25.038772 2020] [php7:error] [pid 1780] [client 113.255.208.74:49893] PHP Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in /var/www/html/validate.php:25\nStack trace:\n#0 /var/www/html/validate.php (9): validateUser('d', 'd')\n#1 {main}\n thrown in /var/www/html/validate.php on line 25, referer: http://113.255.248.189/
<?php
include 'start0.php';
file_put_contents('debug.log', date('Y-m-d H:i:s') . ": Application start ...\n");
error_reporting(E_ALL);
$username = isset($_POST['username']) ? $_POST['username'] : false;
$password= isset($_POST['password']) ? $_POST['password'] : false;
$resp = (object) ['status' => false];
if ($username && $password) {
$resp->status = validateUser($username, $password);
if ($resp->status) {
$resp->url = 'secure.php';
}
}
function validateUser($username, $password) {
$serverName = "182.173.77.220,59365";
file_put_contents('debug.log', "\tAttempting connection ...\n", FILE_APPEND);
$uid = "ws_login";
$pwd = "Ws345678";
$databaseName = "house_sch";
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd,
"Database"=>$databaseName);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
die(json_encode($resp));
$tsql = "SELECT user_Name FROM user_master";
/* Execute the query. */
$stmt = sqlsrv_query( $conn, $tsql);
if ( $stmt )
{
echo "Statement executed.<br>\n";
}
else
{
echo "Error in statement execution.\n";
die( print_r( sqlsrv_errors(), true));
}
if( $conn ) {
echo "Connection established.<br />";
file_put_contents('debug.log', "\tConnection established...\n", FILE_APPEND);
}
else
{
echo "Connection could not be established.<br />";
file_put_contents('debug.log', "\tConnection Failed...\n" . print_r(slsrv_errors(), true), FILE_APPEND);
die( print_r( sqlsrv_errors(), true));
}
return true;
}
?>
Uncaught Error: Call to undefined function sqlsrv_connect()
<?php
phpinfo();
And then search that page for sqlsrv - checking if has been installed. The error is pretty clear though - the library is not available.
you don't have permissions to create the debug.log file.
also try to refer and configure the setting mentioned below:
error_reporting
https://www.php.net/manual/en/function.error-reporting.php