scrooby
07-14-2008, 08:49 PM
I am very new to php and I am trying to do a If Else statement, this is what I have so far:
<?php
if(isset($_SESSION['myusername']))
echo "Welcome ". $_SESSION['myusername'];
else
?>
<form action="checklogin.php" method="post" name="form1">
<input type="text" name="myusername" value="john" id="myusername"> <input type="password" name="mypassword" value="1234" id="mypassword"><input type="submit" value="Login" name="Submit">
</form>
<?php
;
?>
My problem is, is that I dont know where to put the form because i want it to say, if there is a session active, say hello session value, if not, display the login form. At the moment it displays the hello session value but also displays the form because its not in the php tags but i dont know where and how to put it ?
Scrooby
<?php
if(isset($_SESSION['myusername']))
echo "Welcome ". $_SESSION['myusername'];
else
?>
<form action="checklogin.php" method="post" name="form1">
<input type="text" name="myusername" value="john" id="myusername"> <input type="password" name="mypassword" value="1234" id="mypassword"><input type="submit" value="Login" name="Submit">
</form>
<?php
;
?>
My problem is, is that I dont know where to put the form because i want it to say, if there is a session active, say hello session value, if not, display the login form. At the moment it displays the hello session value but also displays the form because its not in the php tags but i dont know where and how to put it ?
Scrooby