Jump to content

Archived

This topic is now archived and is closed to further replies.

bcraig

Login problems

Recommended Posts

I used Dreamweaver to make a "supplies.php" that has a login link. The link takes you to login.php that I made using DW's user auth. behaviors. When the correct login is enterd you are redirected back to "suppliers.php" and the "Login" link should be replaced with "Logout". This is not working. The login works and redirects, its just the "suppliers.php" page doesnt swap the "Login" with "Logout"

 

Here the code for login.php and suppliers.php

 

login.php

<?php require_once('Connections/conn_features.php'); ?>
<?php
// *** Start the session
if (!session_id()) session_start();
// *** Validate request to log in to this site.
$FF_LoginAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && $HTTP_SERVER_VARS['QUERY_STRING']!="") $FF_LoginAction .= "?".htmlentities($HTTP_SERVER_VARS['QUERY_STRING']);
if (isset($HTTP_POST_VARS['username'])) {
 $FF_valUsername=$HTTP_POST_VARS['username'];
 $FF_valPassword=$HTTP_POST_VARS['password'];
 $FF_fldUserAuthorization="";
 $FF_redirectLoginSuccess="suppliers.php";
 $FF_redirectLoginFailed="login.php?badlogin=true";
 $FF_rsUser_Source="SELECT username, password ";
 if ($FF_fldUserAuthorization != "") $FF_rsUser_Source .= "," . $FF_fldUserAuthorization;
 $FF_rsUser_Source .= " FROM users WHERE username='" . $FF_valUsername . "' AND password='" . $FF_valPassword . "'";
 mysql_select_db($database_conn_features, $conn_features);
 $FF_rsUser=mysql_query($FF_rsUser_Source, $conn_features) or die(mysql_error());
 $row_FF_rsUser = mysql_fetch_assoc($FF_rsUser);
 if(mysql_num_rows($FF_rsUser) > 0) {
   // username and password match - this is a valid user
   $MM_Username=$FF_valUsername;
   session_register("MM_Username");
   if ($FF_fldUserAuthorization != "") {
     $MM_UserAuthorization=$row_FF_rsUser[$FF_fldUserAuthorization];
   } else {
     $MM_UserAuthorization="";
   }
   session_register("MM_UserAuthorization");
   if (isset($accessdenied) && false) {
     $FF_redirectLoginSuccess = $accessdenied;
   }
   mysql_free_result($FF_rsUser);
   session_register("FF_login_failed");
$FF_login_failed = false;
   header ("Location: $FF_redirectLoginSuccess");
   exit;
 }
 mysql_free_result($FF_rsUser);
 session_register("FF_login_failed");
 $FF_login_failed = true;
 header ("Location: $FF_redirectLoginFailed");
 exit;
}
?>

 

 

suppliers.php

<?php require_once('Connections/conn_features.php'); ?>

<?php

$colname_suppliers = "1";
if (isset($_GET['company'])) {
 $colname_suppliers = (get_magic_quotes_gpc()) ? $_GET['company'] : addslashes($_GET['company']);
}
mysql_select_db($database_conn_features, $conn_features);
$query_suppliers = sprintf("SELECT * FROM suppliers WHERE company = '%s' ORDER BY id ASC", $colname_suppliers);
$suppliers = mysql_query($query_suppliers, $conn_features) or die(mysql_error());
$row_suppliers = mysql_fetch_assoc($suppliers);
$totalRows_suppliers = mysql_num_rows($suppliers);
?>

 

LOGIN AND LOGOUT LINKS 1(this code makes the supplers.php page come up blank)

<?php 
if(isset(($_SESSION['MM_Username'])) && isset(($_SESSION['MM_UserAuthorization']))) { 
 echo '<a href="logout.php" class="link-main" >logout</a>'; 
} 
else { 
 echo '<a href="login.php?page=' . $_SERVER['PHP_SELF'] . '" class="link-main" >Admin Login</a>'; 
} 
?>

 

 

LOGIN AND LOGOUT LINKS 2(Thisis the code ive had working before but it wont now)

<?php if(($_SESSION['MM_Username']) !="") { ?>
   <a href="logout.php" class="adminlink" >logout</a> 
   <?php } ?>

<?php if(($_SESSION['MM_Username']) =="") { ?>
   <a href="login.php?page=<?php echo $_SERVER['PHP_SELF']; ?>" class="adminlink" >Admin 
   Login</a> 
   <?php } ?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.