Re: making FORM dissapear when successful login

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you for your suggestion, but do you care to be more descriptive, maybe some examples would be nice. Can you tell my why the code i have doesnt work? I would love to use sessions, but i was just trying to get an understanding of how the basics work first.

Jonathan wrote:
I think you should use session control after checking for login.

"JHollis" <jhollis@xxxxxxxxx> wrote in message
news:20050105020517.31324.qmail@xxxxxxxxxxxxxxx

I had this code working the way i wanted it to (as far as correct
username and password allowing successful login)...but what i want to
happen now is when a user successfully logs it it will make the login
form disappear and just say successfully logged in or welcome user and a
link below it so they can log off and make the form re-appear.  Below is
the code that i have where i tried to get it to disappear on successful
login, but it stays disappeared all the time.  Can someone please point
out what im doing wrong.  I have tried everything i can think of...and
nothing works.  Im a PHP newbie...so im sure some of you might get a
laugh out of this...if it is real easy.

<---snippet


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> <html> <head> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="top"> <h1>header</h1>

</div>
<div id="leftnav">
<p>

<?php

$username=$_POST['username'];
$password=$_POST['password'];
$db="user";
$server="localhost";
$db_username="root";
$db_password="*******";

$connect = mysql_connect($server,$db_username,$db_password);
if (!$connect) {
die ("could not connect to database");
}
$select = mysql_select_db($db,$connect);
if (!$select) {
die ("could not select database $db");
}
 /*username='$username'";*/
$sql = "SELECT * FROM passwords, user_info where id=PID and
username='$username'";
$result = mysql_query($sql);
/*$num_rows = mysql_num_rows($result);*/
while ($user = mysql_fetch_array($result))
{
$id = $user['id'];
$username2 = $user['username'];
$password2 = $user['password'];
$firstname = $user['firstname'];
$email = $user['email_address'];


IF ($username=="$username2" && $password=="$password2") { echo("\"Welcome, <b>$firstname</b>\"");?><br><? echo ("\"Your email address is <b>$email<b>\"");?></td><tr> <a href="<?$_SERVER['PHP_SELF']?>?username=""&?password=""">Logoff</a><? break; } else { ?> <FORM action="<?$_SERVER['PHP_SELF']?>" method="post"> <INPUT type="hidden" name="id"> <table> <td><b>*</b>Username:</td> <td><INPUT class="input" size="8" type="text" name="username" value="<?echo $username?>"></td><tr> <td><b>*</b>Password:</td> <td><INPUT class="input" size="8" type="password" name="password"></td><tr> <td class="xsmall"><b>* Case Sensitive</b></td> <td><INPUT type="submit" value="Login"></td><tr> <td>&nbsp </td> </table> </FORM> <?

break;
}

}
//IF ($username != $username2 || $password != $password2) {//



?><br>
<?
if  ($username == "" && $password == "") {
echo ("Please type in a Username and Password");}

if  ($username != "" && $password == "") {
echo ("Please type in a password");}

if  ($username == "" && $password != "") {
echo ("Please type in a username and password");}

?>


</p> </div> <?if (($username2==$username && $password2==$password) && ($username2!="" || $password2!="")){?> <div id="rightnav" class="box"> <p> </p> </div> <?}?> <div id="content"> <h2>Subheading</h2> <p> </p> <p> </p> </div> <div id="footer"> <p> Today is <?php echo( date("F dS Y.")); ?> </p> </div> </div> </body> </html> ---->snippet

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux