Login Script & Dreamweaver

Hi guys

I’ve got a login script that passes the username to a profile page if a successful login. The profile page says Welcome “username”

That’s all working perfectly

What I need help with now tho, is I use dreamweaver to create my websites and with that I need to create a recordset on the profile to pull the details of my customer based on the session “username” as the filter, this is turn should produce a dynamic table and allow the view of the PDF files of their estimate and invoices to which are stored in the Dbase.

Here is the code from 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]

When I run it at the moment, it returns blank fields for the records. I must be doing something wrong in terms of re-using the session within dreamweaver

The site can be found at http://scotair.noip.me

Have you printed out your sql query to make sure it is what you think it is?

echo $query_limit_Recordset1
die

Hiya

No, I put all my trust into Dreamweaver and use their functions etc with the expcetion of the login script as this was a download, but that section does work. The only thing that’s failing or that I cant figure out is how to use the current session showing the username from the login script.

I need to set that session somehow in dreamweaver to allow dreamweaver to use it as the filter on the recordset.

So far you login with Username: Alex and password, it re-directs to profile.php and says “Welcome Alex” I have tried to set the session variable in dreamweaber on the recordset filter as $Login_Session but that returns blank fields

Have you tried setting $_SESSION[‘login’]=$user (using login as a key , rather than a random key )
Then echo $_SESSION and see what values are set.

Ho haven’t tried that. How would I enter that into dreamweaver? Would I just edit the profile.php in code and find it?

I haven’t used Dreamweaver in forever, but I know you can add the php code in Dreamweaver. It does have to be a php page, rather than a regular html page.

Yeah all my pages in php format

I know in the recordset you get the options on filter: Cookie Session, URL Para, Session Variable and Server Variable and next to that there is a form field for entering the filter = username. I know that if I built the login myself through dreamweaver I would use the MM_Username as DW sets that session automatically, but unfortunatly DW 2004 is out of date in the php so the code doesnt work or at least I don’t think it does for me.

I know the session in the login sript I downloaded calls on $login_Session which is the username from login.php.

Would it be easier if I gave you ftp access to the site and if you have any free time kinda of look and explain it?

I just added a formfield on the Profile page and named it username. So now my page looks like this:

Welcome “alex” - Username from Login page via Session script (Outwith DW)

Username:

Records: ID: Username: Password

If I enter alex manually into the formfield and submit via button, it updates the recordset and display his ID username and password using the filter in recordset as Form Variable

If someone can help me figure out the session variable used from the login page that transfers the username to profile.php it should work?

print_r($_SESSION) will display the values in the session variable, and in other pages you can access the session variable just like you do with get or post.

so would I put the print_r in the formfield as a default value?

Hey Guys

Thought I would just drop a quick update.

I managed to get everything working within dreamweaver after a looked a little harder at the coding.

I left out at the top of the profile page
[php]

<?php if (!isset($_SESSION)) { session_start(); } ?>[/php]

So now the login.php sends the username to profile.php and says welcome “username” and further down I have a dynmaic table linked by the session username displaying the contents of the DB only for that user.

3 days banging my head for a silly little bit of code that I overlooked

THanks for you help

Thanks for posting your answer!

Sponsor our Newsletter | Privacy Policy | Terms of Service