isharie Posted May 22, 2013 Share Posted May 22, 2013 <!DOCTYPE HTML> <html> <head> <title>Fife council</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> </head> <body> <div data-role="header"> <h1>Fife council</h1> </div> <div data-role="navbar"> <ul> <li><a href="register.php" data-transition="flip">Register</a></li> <li><a href="index.php" data-transition="flip">Home</a></li> </ul> </div><!-- /navbar --> <div data-role="content" data-id="cont"> <?php if (isset($_POST['password'], $_POST['username'])) { $username = strtolower(strip_tags($_POST['username'])); $password = strip_tags($_POST['password']); $connect = mysql_connect("localhost","root",""); { if (empty ($username) || empty($password)) { $errors[] ='All fields are required'; } $query = mysql_query("SELECT username FROM users WHERE username ='$username'"); $numrows = mysql_num_rows($query); if ($numrows <1) { $errors[] ='Please enter a valid username'; } $query = mysql_query("SELECT password FROM users WHERE username ='$username'"); $numrows = mysql_num_rows($query); if ($numrows <1) { $errors[] ='Invalid password'; } if(!empty($errors)) { foreach ($errors as $errors) { echo '<strong>',$errors ,'</strong><br />'; } }else{ if ($username&&$password) { $connect = mysql_connect("localhost","root","") or die ("Could not connect"); mysql_select_db ("mobile") or die ("Could not find database"); $query = mysql_query("SELECT * FROM users WHERE username ='$username'"); $numrows = mysql_num_rows($query); if ($numrows !=0) { while ($row =mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&$password==$dbpassword) { echo header( 'Location: member.php' ) ; $_SESSION['username']=$dbusername; } } } } } } ?> <div id ="loginForm" align="center"> <fieldset data-role="fieldcontain"> <form id='login' action='' method='post' accept-charset='UTF-8' data-transition="flip""> <fieldset> <input type='hidden' name='submitted' id='submitted' value='1'/> <label for='username' >UserName*:</label> <input type='text' name='username' id='username' maxlength="50" /> <label for='password' >Password*:</label> <input type='password' name='password' id='password' maxlength="50" /> <input type='submit' name='Submit' value='Submit'/> </fieldset> </form> </div> </div><!-- /content --> <div data-role="footer" data-id="foo1"> <h1>Footer</h1> </div><!-- /footer --> </body> </html> Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in E:\EasyPHP-12.1\www\my portable files\mobilelo1\loginform.php on line 41Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in E:\EasyPHP-12.1\www\my portable files\mobilelo1\loginform.php on line 48Please enter a valid usernameInvalid password Error messages It should only display error massages and it should let me log in, it's not letting me do anything at the moment any advice would be good. Quote Link to comment Share on other sites More sharing options...
isharie Posted May 22, 2013 Author Share Posted May 22, 2013 Never mind I'm an idiot I forgot to do a few things.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.