PHP session

Hi guys

I have got a login script that uses a session to display the username on a profile page once they have logged in. The login came to me as a srcipt, I use dreamweaver and I’m trying to create a user account kind of thing on the profile page, so when a customer logs in they see only their estimates and invoices.

Here is the code form the profile page

[php]<?php require_once('../Connections/new.php'); ?>

<?php $maxRows_Recordset1 = 10; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; $colname_Recordset1 = "1"; if (isset($_SESSION['$login_session'])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['$login_session'] : addslashes($_SESSION['$login_session']); } mysql_select_db($database_new, $new); $query_Recordset1 = sprintf("SELECT * FROM login WHERE username = '%s'", $colname_Recordset1); $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $new) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; $colname_Recordset1 = "1"; if (isset($_SESSION['<?php echo $login_session; ?>

‘])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION[’<?php echo $login_session; ?>’] : addslashes($_SESSION[’<?php echo $login_session; ?>’]); } mysql_select_db($database_new, $new); $query_Recordset1 = sprintf(“SELECT * FROM login WHERE username = ‘%s’”, $colname_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $new) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?>

<?php include('session.php'); ?> Your Home Page
Welcome : <?php echo $login_session; ?> <?php do { ?> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
id username password
<?php echo $row_Recordset1['id']; ?> <?php echo $row_Recordset1['username']; ?> <?php echo $row_Recordset1['password']; ?>
Log Out
<?php mysql_free_result($Recordset1); ?> [/php]

I have created the recordset to display the ID, Username and Password but it returns blank fields, so I’m assuming I’ve not setup something.

The session works as it grabs the username from the login page, and on the profile page it says “welcome - Alex” alex being a test username?

The page can be seen at http://scotair.noip.me

Any help would be great

Try setting a session key, and add the php code to your files in dreamweaver, making sure you are creating php pages, rather than html.

Sponsor our Newsletter | Privacy Policy | Terms of Service