Click to See Complete Forum and Search --> : [RESOLVED] form output within an IF statement?


DMP23
04-20-2006, 02:29 PM
having trouble outputting my form within an if statement. what i want to achieve is:

if the cookie is set to 1 - the user is loggin in , so great the user. if they are not logged in print the login form.

please advise

my curent code is:
<?php
if($_COOKIE['login']==1)
{
print "Hello ".$_COOKIE[firstname];
}
else
{
<FORM METHOD="POST" ACTION="frontpage3.php">
<strong>Username:</strong><br>
<INPUT TYPE="text" NAME="username">
<p><strong>Password:</strong><br>
<INPUT TYPE="password" NAME="password"><br>
<br><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Login">
<p>
If you are not a registered user please register <a href="index_register2.html">here</a> </p>
</FORM>
}
?>

bokeh
04-20-2006, 02:37 PM
You need a means of storing all the legal username and pasword combinations (either database of file).

DMP23
04-20-2006, 02:56 PM
i have a DB of registered users and passwords but just want to get the if going to it will recognize whether or not the user is logged in or not (when they click the home button again) but use of the cookie. get me ?

NogDog
04-20-2006, 05:43 PM
<?php
if($_COOKIE['login']==1)
{
print "Hello ".$_COOKIE[firstname];
}
else
{
?>
<FORM METHOD="POST" ACTION="frontpage3.php">
<strong>Username:</strong><br>
<INPUT TYPE="text" NAME="username">
<p><strong>Password:</strong><br>
<INPUT TYPE="password" NAME="password"><br>
<br><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Login">
<p>
If you are not a registered user please register <a href="index_register2.html">here</a> </p>
</FORM>
<?php
}
?>