php login

Hello Everyone,

I am just getting into php and was looking for some advice/help. Thanks for any responces! So I am trying to make a simple username and password login to access a page with some reports on it. I had previously built a quick easy one with php and mysql that worked for our needs but apparently switching it over to server 2008 with iis and sql server 2008 was harder than i thought.

I have a sql table with collumns username and password. populated in that table there is only one username and password at the moment. I have a loginpage with a submit form that submits to data.php.

data.php:
[php]

<?php $username = $_POST['username']; $password = $_POST['password']; // Connect to the server. $server = "localhost"; $uid = "web"; $pwd = "123456"; $database = "weblogins"; $connectionoptions = array("Database" => $database , "UID" => $uid , "PWD" => $pwd); $conn = sqlsrv_connect($server, $connectionoptions); // Execute a parameterized query. $params = array($username, $password); $sql = "SELECT * FROM login WHERE username = ? and password = ?"; $stmt = sqlsrv_query($conn, $sql, $params); $numrows = sqlsrv_num_rows($stmt); if ($numrows =1) { echo "You're in! Click here to enter the member page"; $_SESSION['username']=$username; } else { echo "Incorrect password"; } ?>

[/php]

with that code i get Warning: sqlsrv_num_rows() expects parameter 1 to be resource, boolean given in …

so im not sure if I am on the right track with this whole setup lol. I think that error is because i need to set a cursor but yeah im totally confused on that. came accross this article http://msdn.microsoft.com/en-us/library/ee376927.aspx but every time i try and add something it either brings me to a blank page or errors with the same error lol. If anyone has any articles or examples that might help would be appreciated :slight_smile:

thanks again!

Whats the address of the site where you are getting the error?

I hope to god that is not your real database password if it is change it before you tell anyone what your website address is :stuck_out_tongue:

no of course not. and this site wont be availible out of our office lol.

Sponsor our Newsletter | Privacy Policy | Terms of Service