Page 1 of 1

login page php

Posted: Thu Apr 12, 2012 8:33 am
by umar123
I am currently trying to make a log in page for my website i am following this tutorial on youtube http://www.youtube.com/watch?v=4oSCuEtxRK8
however i currently have a problem


<form method="POST" action='login.php'>
Username<input type='text' name='username'></br>
Password<input type='password' name='password'></br>
<input type='submit' value='Log in'>
</form>

and my login page code atm is
<?php

$username = $_ POST('username');
$password = $_ POST('password');

if ($username&&$password)
{
$connect = mysql_connect("localhost","root","")or die ("couldn't connect");
mysql_select_db("mylogin") or die ("could not find the database");

else die("please enter a username and password");

}

?>


it says that i have got a promeblem at line 3 in my login page which satrts $username it gives me a T_string error saying that it does not recognise username or password.

Re: login page php

Posted: Thu Apr 12, 2012 8:51 am
by Celauran
You reference an array item using brackets, not parentheses.

Code: Select all

$username = $_POST['username'];
Any tutorial advocating the use of mysql_connect et al. isn't worth following.

Re: login page php

Posted: Thu Apr 12, 2012 9:02 am
by umar123
i tried that as well this is the error message that comes up Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\prototype\login.php on line 3

Re: login page php

Posted: Thu Apr 12, 2012 9:05 am
by Celauran
You've got the same mistake on the very next line, and you've got your else statement inside your if block.