I'm very new to PhP and one of my asignments in class is to create a simple login using php and mysql. I made a simple page using html, php, and mysql and i keep getting errors. Here is my code so far:
This is my index.php page:
<html>
<form action = 'login.php' method='POST'>
Username: <input type='text' name='username'><br>
Password: <input type='password' name='password'><br>
<input type='submit' value='Log in'>
</form>
</html>
This is my login.php page:
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
&connect = mysql_connect("localhost", "root", " ") or die ("Couldnt connect");
mysql_selct_db("phplogin") or die("Couldn't find db");
}
else
die ("Please enter a username and password");
?>
mySql file is very basic: 3 columns, id, username, password
I dont think my problem is with the mySQL page that was the easiest to make
but everytime I hit login in the index.php, the entire script for login.php gets outputted on screen.
I would appreciate all the help.