Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your code, after connecting to the database, you are directly executing a query "SELECT nAuthID FROM tAccounts" which will fetch all the available nAuthID's from the table.</p> <p>Your query should authenticate the user after entering the login details in your login form. So your query in your code should be some thing like below... </p> <pre><code>&lt;?php $myServer = "Farbod-PC\SQLExpress"; $myUser = "user"; $myPass = "pass"; $myDB = "Account"; $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); // $query = "SELECT nAuthID FROM tAccounts"; //Your Query Should be something like this $query = "SELECT nAuthID FROM tAccounts WHERE sUsername='MrFarbodD' AND sUserpass= 'yourpassword' "; $result = mssql_query($query) or die('A error occured: ' . mysql_error()); /*while ( $record = mssql_fetch_array($result) ) { die ($record ['nAuthID']); } */ if(mssql_num_rows($result)&gt;0){ $record = mssql_fetch_array($result); $nAuthID = $record ['nAuthID']; session_start(); $_SESSION['nAuthID'] = $nAuthID; }else{ echo 'Login Failed'; } mssql_free_result($result); mssql_close($dbhandle); ?&gt; </code></pre> <p>Please make sure that you will be passing the dynamic values to the query. and make a note that you can use the session variable $_SESSION['nAuthID'] to get nAuthID whereever you want to display.</p> <p>By doing so, you will be getting nAuthID of a particular user who have logged in successfully. Also, you can use else loop if the authentication failed and redirect the user back to login screen.</p> <p>Hope this clarify your doubt??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload