Zenax
Active Member
- Messages
 - 1,377
 
- Reaction score
 - 4
 
- Points
 - 38
 
Perhaps you can help me out here.
The script I have is not remembering sessions. I think i am creating them correctly. Here is the code:
	
	
	
		
Page:
http://zenax.x10hosting.com
They must be created, as I use the session function to call the username once they have logged in, sos urely they ar ebeing created???
			
			The script I have is not remembering sessions. I think i am creating them correctly. Here is the code:
		PHP:
	
	<?php
            session_start();
            
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ZenCMS</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="tabs/ajaxtabs/ajaxtabs.js">
/***********************************************
* Ajax Tabs Content script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
</head>
<body>
<div class="topBar">
    <div class="logo">
    
        <img src="img/logo.jpg" width="400" height="100" alt="ZenCMS" />
        
    </div>
    
    <div class="form">
    
        <div class="formContent">
            <?php
            
            
        // Require once the DB script
        require_once('connect_db.php');
        $username = $_POST['username'];
        $password = $_POST['password'];
        // Creating an SQL Query
        $q = "SELECT * FROM users WHERE  users = '$username' and password = '$password'";
        $check = mysql_query($q);
        // Counting the table row
        // If the result is matched then $username, $password must be row 1
        $count = mysql_num_rows($check);
        if ($count == 1) {
            
            $_SESSION['username'] = $username;
            $_SESSION['password'] = $password;
        
            if ($_SESSION['username'] = 'Admin')    {
            echo '<a href="ap">Admin Panel</a> <br />';
            }
            
            echo 'Welcome '. $_SESSION['username'] .'. You are now logged in!';
            echo '<br />';
            echo '<a href="logout.php">Logout</a>';
            
            
        }
        
        elseif ($count == 0)    {
        echo 'Wrong username or password specified';
        echo '<a href="#" onClick="history.back(1)">Go Back</a>';
        }
        
        else {        
?>
            <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
            <table width="90%" border="0" cellspacing="0" cellpadding="5">
                  <tr>
                    <td>Username:</td>
                    <td>Password:</td>
                  </tr>
                  <tr>
                       <td><input type="text" name="username" /></td>
                    <td><input type="password" name="password" />   <input name="submit" type="submit" value="Login" class="button"/></td>
              </tr>
            </table>
            </form>
        <?php
        
        }
        
        ?>
      </div>
    </div>
</div>
<div class="rightCol">
    <div class="title">
    Website News
    </div>
    
    <div class="info">
    
        <i>New Template - 04 July 2007</i>
        <br />
        I have created a brand new template. The reason behind this is so that I can sort things out witha  dodgy phpBB 3 installation I had once, and also continue writing my own CMS. This template is based on partly things I have written so far. The login feature at the top of the page is curently based on the membership feature that is based within the CMS. 
        
        <br />
        <br />
        
        I am in the process of writing the rest of the CMS and you can find out information on this CMS by visiting the relevant pages behind it!
        
        <br />
        <br />
        If you have any problems, then please do not hesitate to contact me by visting the contact page!
        <br />
        <br />
        Regards,
        <br />
        ZenCMS Admin
    
    </div>
<br />
<?php
 echo file_get_contents("http://staff.x10hosting.com/adCode.php?ad=advanced"); 
 
?>
</div>
<div class="navTop">
12435
</div>
<div class="topBoxes">
<ul id="maintab" class="shadetabs">
<li class="selected"><a href="#default" rel="ajaxcontentarea">About</a></li>
<li><a href="tabs/external.htm" rel="ajaxcontentarea">Latest Release</a></li>
<li><a href="tabs/external2.htm" rel="ajaxcontentarea">Problems?</a></li>
</ul>
<div id="ajaxcontentarea" class="contentstyle">
    <strong>About</strong>
    ZenCMS is the product of a very bored teenage on his 3 month break from college. In my spare time, I am writing this CMS as a way to pass the time, but also to see how far I can push myself creatively and also how much coding knowledge I actually have.
</div>
<script type="text/javascript">
//Start Ajax tabs script for UL with id="maintab" Separate multiple ids each with a comma.
startajaxtabs("maintab")
</script>
    
</div>
</body>
</html>
	Page:
http://zenax.x10hosting.com
They must be created, as I use the session function to call the username once they have logged in, sos urely they ar ebeing created???
			
				Last edited: