login page php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
umar123
Forum Newbie
Posts: 2
Joined: Thu Apr 12, 2012 8:26 am

login page php

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: login page php

Post 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.
umar123
Forum Newbie
Posts: 2
Joined: Thu Apr 12, 2012 8:26 am

Re: login page php

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: login page php

Post by Celauran »

You've got the same mistake on the very next line, and you've got your else statement inside your if block.
Post Reply