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!
Hello,
I just started using PHP and MYSQl a little while ago and now i want to make a login in script on every page that i have in like the menu, i can do that but i want it to disapear after i have logged in, and memeber stuff to come up, iv tried using if statements but i dont know what to do.
My code is below:
<form method=post action="<?echo $PHP_SELF?>">
<table cellpadding=2 cellspacing=0 border=0>
<td>Username:</td><td><input type="text" name="username" size=10></td><tr>
<td>Password:</td><td><input type="password" name="password" size=10></td><tr>
<td> </td><td><input type="submit" name="submit" value="Log In"></td>
</table></form>
<?
if ($submit) {
$user_name=$_POSTї'username'];
$password=$_POSTї'password'];
$db=mysql_connect("localhost","root") or die ("Unable to connect.");
mysql_select_db("main",$db) or die ("Wrong Database information or error in coding.");
$query="Select * from Userbase where Account='$username' AND password='$password'";
$result=mysql_query($query, $db) or die ('ERROR');
$affected_rows=mysql_num_rows($result);
if ($affected_rows == 1) {
echo "You logged in!";
$_SESSIONї'username'] = $username;
} else {
echo ".";
}
}
?>
What would i do to make that stuff disapear after login, and only appear if ur not logged in, and how would i make stuff appear? Any help is greatly appreciated.
i would really like the login page to have more stuff on it, how do i add stuff b4 it w/o scewing up stuff?
and lets say once i have the session running and im on a different page, can i set up an if statement with a varible from the login page so that it shows something else?
im having trouble setting up the username and password thing to access the database...
well thanks for the help but now im so confused, lol.
i still dont really know alot about php, but i just need a stupid login script lol that will show stuff and i dont know how to do it, thanks for the help.