Copy link to clipboard
Copied
Hi i am working with dreamweaver cs5.5 and i am making php pages so users can login. I do not know how to replace the login form with a logout form once logged in. Can anyone help please, i will be very greatfull.
lol all i needed is to make sure i had the php in "<?php XXXXXX ?>"
Copy link to clipboard
Copied
i have tryed this "http://www.plus2net.com/php_tutorial/php_login_logout.php" but i cant get it to work....
Copy link to clipboard
Copied
The coding method is simple: just create an if/else statement in your config file where if user is logged in the show logout button else show login form. Then call the function wherever you want it to appear. This is very basic/beginner php coding methods. Perhaps more than asking about this technique you should be asking how php coding works. There are entire books that explain how php works. If/else statements are very baic in the grand scheme of php coding. focus on the exact element that you are having trouble und3rstanding vs. the function you want to acheive. If you do that then the coding for your desired function will come easily!
best,
Shocker
Copy link to clipboard
Copied
Thanks for the help, can you recomend a book for me?
Copy link to clipboard
Copied
This is the code im using for the forms, so far the forms are on defferent pages ( because and can't get the if/else to work ), when i use the code in this link "http://www.plus2net.com/php_tutorial/php_login_logout.php
" i add the code to one page but it just doesnt work...
This is on the page i want to use as the main template. Do i need more files for this to work?
<div id="header">
<table width="100%" cellpadding="5">
<tr>
<td width="1022"><table>
<tr>
<td class="tablebg">Gamers</td>
</tr>
</table></td>
<td width="300" rowspan="2" align="right" nowrap="nowrap">
<?
if(isset($session[MM_Username])){ // Member is logged in so we have to display welcome message with userid and one logout link
echo "
<form id="form1" name="form1" method="post" action="">
<p> Welcome <?php echo $_SESSION['MM_Username']; ?>! <a href="<?php echo $logoutAction ?>">
<input type="button" name="log out" id="submit" value="Log Out!" /></a> </p>
</form>";
}else { // Member has not logged in so we can display the login form allowing member to login with user id and password
echo "<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<p>
<label for="username">Username/E-Mail</label>
<input type="text" name="username" id="username" />
</p>
<p>
<label for="password">Password</label>
<input type="text" name="password" id="password" />
</p>
<p>
<a href="../register.php"><input type="button" name="register" id="register" value="Register Now!" /></a>
<input type="submit" name="submit" id="submit" value="Login!" />
</p>
</form>";
} // End of else condtiion echo "</table>"; (i dont get this </table> tage here)
?>
</td>
</tr>
<tr>
<td><ul id="MainNav" class="MenuBarHorizontal">
<li><a href="../home.php">Home</a></li>
<li><a href="#">Forum</a></li>
<li><a href="#" class="MenuBarItemSubmenu">Games</a>
<ul>
<li><a href="#">C.O.D</a></li>
<li><a href="#">CounterStrike</a></li>
<li><a href="#">Planetside</a></li>
</ul>
</li>
<li><a href="#">Members</a></li>
<li><a href="#">Contact</a></li>
<li><a href="../about.php">About</a></li>
</ul></td>
</tr>
</table>
</div>
Sorry, i am new to this.
Copy link to clipboard
Copied
Ok I have got something working except only on a page that I have restricted access to. I also have to use links to a form, I can't put the form (login logout form) on the same page. I am using the if else on the main template and it only works when I restrict a page, can anyone give me a clue why?
Copy link to clipboard
Copied
lol all i needed is to make sure i had the php in "<?php XXXXXX ?>"