
Nov 19th, 2007, 18:46
|
|
Reputable Member
|
|
Join Date: Jul 2006
Location: Baldock
Age: 20
Posts: 447
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Re: [SOLVED] PHP Logout Message when redirect
here is the login. php, aboutusshop. php and the index. php attached to this document.
login. php
- PHP: Select all
<?php require_once ( 'settings.php' ); if ( array_key_exists ( '_submit_check', $_POST ) ) { if ( $_POST['username'] != '' && $_POST['password'] != '' ) { $query = 'SELECT ID, Username, Active, Password FROM ' . DBPREFIX . 'users WHERE Username = ' . $db->qstr ( $_POST['username'] ) . ' AND Password = ' . $db->qstr ( md5 ( $_POST['password'] ) ); if ( $db->RecordCount ( $query ) == 1 ) { $row = $db->getRow ( $query ); if ( $row->Active == 1 ) { set_login_sessions ( $row->ID, $row->Password, ( $_POST['remember'] ) ? TRUE : FALSE ); $_SESSION['username'] = $username; header ( "Location: " . REDIRECT_AFTER_LOGIN ); } elseif ( $row->Active == 0 ) { $error = 'Your membership was not activated. Please open the email that we sent and click on the activation link.'; } elseif ( $row->Active == 2 ) { $error = 'You are suspended!'; } } else { $error = 'Login failed!'; }
} else { $error = 'Please use both your username and password to access your account'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>roScripts.com - PHP Login System With Admin Features</title> <link href="css/styles.css" rel="stylesheet" type="text/css" /> <!-- ____ __ /\ _`\ __ /\ \__ _ __ ___\ \,\L\_\ ___ _ __ /\_\ _____\ \ ,_\ ____ /\`'__\/ __`\/_\__ \ /'___\/\`'__\/\ \/\ '__`\ \ \/ /',__\ \ \ \//\ \L\ \/\ \L\ \/\ \__/\ \ \/ \ \ \ \ \L\ \ \ \_/\__, `\ \ \_\ \____/\ `\____\ \____\ \_\ \ \_\ \ ,__/\ \__\/\____/ \/_/ \/___/ \/_____/\/____/ \/_/ \/_/\ \ \/ \/__/\/___/ \ \_\ \/_/ Making your world easy --> </head> <body> <div id="log"> <?php if ( isset( $error ) ) { echo ' <p class="error">' . $error . '</p>' . "\n";}?> </div> <div id="container" style="width:230px;"> <form class="form" action="<?=$_SERVER['PHP_SELF']?>" method="post"> <input type="hidden" name="_submit_check" value="1"/>
<div style="margin-top:12px; margin-bottom:10px"> <img src="images/username.gif" alt="username" border="0" /> <input class="input" type="text" name="username" id="username" size="25" maxlength="40" value="" /> </div> <div style="margin-bottom:6px"> <img src="images/password.gif" alt="password" border="0" /> <input class="input" type="password" name="password" id="password" size="25" maxlength="32" /> </div> <?php if ( ALLOW_REMEMBER_ME ):?> <div style="margin-bottom:6px"> <input type="checkbox" name="remember" id="remember" /> <label for="remember">Remember me</label> </div> <?php endif;?> <input type="image" name="Login" value="Login" class="submit-btn" src="images/btn.gif" alt="submit" title="submit" /> <br class="clear" /> <a href="register.php">Register</a> / <a href="forgot_password.php">Password recovery?</a>
</form>
<!-- Keeping the link below not only gives respect to the large amount of time given freely by me but also helps build interest, traffic and use of this script. It's not required but recommended since it also might affect my support priorities on the forums.
Thank you, Mihalcea Romeo - roScripts.com // --> <?=powered_by ()?>
</div>
</body> </html>
aboutusshop. php
- PHP: Select all
<?php // NOTHING ABOVE HERE (not even opening <html> tag or Doctype if (!isset($_SESSION['username'])) { header("Location: /?login"); // if they are not logged in, go to the index page) } // By here put the actual page ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Music Shop</title> <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
</head> <body> <div id="wrapper"> <h1><em>ABOUT</em></h1> <div id="nav"> <ul> <li><a href="http://www.qwhosting.co.uk/aboutshop.php"><span>01</span> About Shop</a></li> <li><a href="http://www.qwhosting.co.uk/gallery.php"><span>02</span> Gallery</a></li> <li><a href="http://www.qwhosting.co.uk/freemusic.php"><span>03</span> Free Music</a></li> <li><a href="http://www.qwhosting.co.uk/artist.php"><span>04</span> Artist</a></li> <li><a href="http://www.qwhosting.co.uk/contact.php"><span>05</span> Contact</a></li> <li><a href="http://www.qwhosting.co.uk/login/login.php"><span>06</span> Login</a></li> <li><a href="http://www.qwhosting.co.uk/login/register.php"><span>07</span> Register</a></li> <li><a href="http://www.qwhosting.co.uk/login/members.php"><span>07</span> Admin</a></li> </ul> </div> <div id="topcon"> <div id="topcon-inner"> <h2>Welcome to Music Shop</h2> <p></p>
</div> </div> <div id="content"> <div id="body"> <div class="box" id="news"> <div class="box-t"><div class="box-r"><div class="box-b"><div class="box-l"> <div class="box-tr"><div class="box-br"><div class="box-bl"><div class="box-tl"> <h2>NEWS & EVENTS</h2> <h3>05.03.2007</h3> <p></p> <div class="hr-yellow"> </div> <h3>05.03.2007</h3> <p></p> </div></div></div></div> </div></div></div></div> </div> <div class="box" id="hits"> <div class="box-t"><div class="box-r"><div class="box-b"><div class="box-l"> <div class="box-tr"><div class="box-br"><div class="box-bl"><div class="box-tl"> <h2>HIT'S LIST</h2> <h3>movie hits</h3>
<div class="hr-yellow"> </div>
<h3>album hist</h3>
</div></div></div></div> </div></div></div></div> </div> <div class="box" id="new"> <div class="box-t"><div class="box-r"><div class="box-b"><div class="box-l"> <div class="box-tr"><div class="box-br"><div class="box-bl"><div class="box-tl"> <h2>NEW RELEASES</h2>
</div></div></div></div> </div></div></div></div> </div> <div class="clear"> </div> </div> <div id="footer"> <ul> <li><a href="http://www.qwhosting.co.uk/pictures.php">PICTURE</a> | </li> <li><a href="http://www.qwhosting.co.uk/gallery.php">GALLERY</a> | </li> <li><a href="http://www.qwhosting.co.uk/freemusic.php">FREE MUSIC</a> | </li> <li><a href="http://www.qwhosting.co.uk/features.php">FEATURES</a> | </li> <li><a href="http://www.qwhosting.co.uk/contacts.php">CONTACTS</a> | </li> </ul> <p>© qwhosting.co.uk <a href="http://www.qwhosting.co.uk">Privacy Policy</a> | <a href="http://www.qwhosting.co.uk/terms.php">Terms of Use</a>.</p> </div> </div> </div> </body> </html>
index. php
- PHP: Select all
<?php session_start(); session_destroy(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Music Shop</title> <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
</head> <body> <div id="wrapper"> <h1><em>MUSIC</em> SHOP</h1> <div id="nav"> <ul> <li><a href="http://www.qwhosting.co.uk/aboutshop.php"><span>01</span> About Shop</a></li> <li><a href="http://www.qwhosting.co.uk/gallery.php"><span>02</span> Gallery</a></li> <li><a href="http://www.qwhosting.co.uk/freemusic.php"><span>03</span> Free Music</a></li> <li><a href="http://www.qwhosting.co.uk/artist.php"><span>04</span> Artist</a></li> <li><a href="http://www.qwhosting.co.uk/contact.php"><span>05</span> Contact</a></li> <li><a href="http://www.qwhosting.co.uk/login/login.php"><span>06</span> Login</a></li> <li><a href="http://www.qwhosting.co.uk/login/logout.php"><span>07</span> Logout</a></li> <li><a href="http://www.qwhosting.co.uk/login/members.php"><span>07</span> Admin</a></li> </ul> </div> <br> <br> <font color="#FFFFFF" size="3"> <?php if (isset($_SESSION['username'])) { echo "welcome ".$_SESSION['username']; } if (isset($_GET['logout'])) { echo "You have Logged Out"; } if (isset($_GET['login'])) { echo "you need to login to view content"; } ?> </br> </font> <div id="topcon"> <div id="topcon-inner"> <h2>Welcome to Music Shop</h2> <p></p>
</div> </div> <div id="content"> <div id="body"> <div class="box" id="news"> <div class="box-t"><div class="box-r"><div class="box-b"><div class="box-l"> <div class="box-tr"><div class="box-br"><div class="box-bl"><div class="box-tl"> <h2>NEWS & EVENTS</h2> <h3>05.03.2007</h3> <p></p> <div class="hr-yellow"> </div> <h3>05.03.2007</h3> <p></p> </div></div></div></div> </div></div></div></div> </div> <div class="box" id="hits"> <div class="box-t"><div class="box-r"><div class="box-b"><div class="box-l"> <div class="box-tr"><div class="box-br"><div class="box-bl"><div class="box-tl"> <h2>HIT'S LIST</h2> <h3>movie hits</h3>
<div class="hr-yellow"> </div>
<h3>album hist</h3>
</div></div></div></div> </div></div></div></div> </div> <div class="box" id="new"> <div class="box-t"><div class="box-r"><div class="box-b"><div class="box-l"> <div class="box-tr"><div class="box-br"><div class="box-bl"><div class="box-tl"> <h2>NEW RELEASES</h2>
</div></div></div></div> </div></div></div></div> </div> <div class="clear"> </div> </div> <div id="footer"> <ul> <li><a href="http://www.qwhosting.co.uk/pictures.php">PICTURE</a> | </li> <li><a href="http://www.qwhosting.co.uk/gallery.php">GALLERY</a> | </li> <li><a href="http://www.qwhosting.co.uk/freemusic.php">FREE MUSIC</a> | </li> <li><a href="http://www.qwhosting.co.uk/features.php">FEATURES</a> | </li> <li><a href="http://www.qwhosting.co.uk/contacts.php">CONTACTS</a> | </li> </ul> <p>© qwhosting.co.uk <a href="http://www.qwhosting.co.uk">Privacy Policy</a> | <a href="http://www.qwhosting.co.uk/terms.php">Terms of Use</a>.</p> </div> </div> </div> </body> </html>
Thanks
Aaron
Last edited by Aaron1988; Nov 19th, 2007 at 18:51.
|