Anesly_Manoj Posted November 13, 2013 Share Posted November 13, 2013 <?php $host="localhost"; $user="root"; $pass="4161"; $db="e_bazaar"; mysql_connect($host,$user,$pass); mysql_select_db($db); session_start(); if(isset($_POST['txt_un'])) { $username = $_POST['txt_un']; $password = $_POST['txt_pass']; $sql = "SELECT * FROM tbl_shop WHERE un='".$username."' AND pass'".$password."' LIMIT 1"; $res=mysql_query($sql); if(mysql_num_rows($res)==1) { echo "You logged in successfully"; echo "<a href=\"home.php\"> :Continue to home page </a>"; exit(); } else { echo "Invalid login in details provided"; echo "<a href=\"login.php\"> :Back to login</a>"; exit(); } } ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted November 13, 2013 Share Posted November 13, 2013 PHPFreaks.com Questions, Comments, & Suggestions This is NOT a help forum! Do not post topics asking for help that are not related to the website. If you had checked the PHP Coding Help forum, where this thread is now located, you might have seen the README: PHP Resources & FAQs sticky which has 6. mysql* expects parameter 1 to be resource, boolean given This means your query failed, for some reason or another. Remove any error suppressing (@), make sure you have error displaying enabled, and output mysqli_error to see specific information about your error! Quote Link to comment Share on other sites More sharing options...
budimir Posted November 13, 2013 Share Posted November 13, 2013 Two things you need to do: 1. Always ue some kind of error reporting. Good practice would be to use: $res=mysql_query($sql) or die (mysql_error()); That will tell you when you have an error in you're query! 2. Problem you are haveing is with you're SQL query. It need's t be like this: $sql = "SELECT * FROM tbl_shop WHERE un='".$username."' AND pass='".$password."' LIMIT 1"; You are missing = after pass! Quote Link to comment Share on other sites More sharing options...
requinix Posted November 13, 2013 Share Posted November 13, 2013 1. Always ue some kind of error reporting. Good practice would be to use: $res=mysql_query($sql) or die (mysql_error()); That will tell you when you have an error in you're query! While developing. Never let that get onto a live site. 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.