Alfraganus Posted August 6, 2015 Share Posted August 6, 2015 I was trying to make log in using mysql too, however, something wring with my "mysql", I am not sure what I did wrong with it, could you please kindly check if there any possibility? login.php: <!DOCTYPE html> <html> <head> <title></title> </head> <body> <form action="Login1.php" method="POST"> Username:<input type="text" name="username"> <br> Password:<input type="password" name="password"> <br> <input type="submit" name="submit" value="log in"> </form> </body> </html> login1.php <?php $username=$_POST ["username"]; $password=$_POST["password"]; if ($username&&$password) { $connect=mysqli_connect("locahost", "root","") or die("can't connect!!"); mysql_select_db("phplog") or die("cant connect!!"); } else die("please enter username and password"); ?> Link to comment Share on other sites More sharing options...
justsomeguy Posted August 6, 2015 Share Posted August 6, 2015 What's the point of that code? You connect to the database but don't do anything else. You're also mixing mysqli and mysql, that doesn't work. Use either mysqli or PDO, do not use regular mysql functions. Link to comment Share on other sites More sharing options...
Alfraganus Posted August 7, 2015 Author Share Posted August 7, 2015 but error exactly coming from line 9 which is $connect=mysql_connect("locahost", "root","") or die("can't connect!!"); what is wrong except mysqli? Link to comment Share on other sites More sharing options...
Ingolme Posted August 7, 2015 Share Posted August 7, 2015 Do you have a MySQL server set up and does it have a user "root" with no password? If you're on a web host you might need to findout their SQL server address, it's not always "localhost". Simply connecting to the database won't do anything to log users in, though. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now