Jump to content

Archived

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

anakalia

DW8 - Login User Error

Recommended Posts

I'm brand new here, I hope no one minds me jumping straight in, but I've been going crazy working on this project!
I'm more of a designer than a coder and have learnt php and MySQL from [i]Foundation PHP for Dreamweaver 8[/i] by David Powers.  This project I'm working on is a website for magazine users to login and manage their  subscription online.  They come across the page login.php and continue on to myhome.php. 
I had been using the session [MM_Username] to show the user's information when they logged in, but everytime, I would get the information for user 1, no matter what user logged in.  After going crazy with that for a while, I decided to try passing the user's id number via a URL Param (user_id) from the login.php page to the myhome.php.  But this is the error I get:
[quote]Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in login.php on line 53[/quote]

And this is the code I'm working with (not all, but what I think is the important parts). The bold line is line 53:

[tt]mysql_select_db($database_userconn, $userconn);
$query_userid = "SELECT user_id, users.username FROM users";
$userid = mysql_query($query_userid, $userconn) or die(mysql_error());
$row_userid = mysql_fetch_assoc($userid);
$totalRows_userid = mysql_num_rows($userid);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  [b]$MM_redirectLoginSuccess = "user/myhome.php?user_id=<?php echo $row_userid['user_id']; ?>";[/b]
  $MM_redirectLoginFailed = "loginfailed.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_userconn, $userconn);
 
  $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
 
  $LoginRS = mysql_query($LoginRS__query, $userconn) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    $loginStrGroup = "";
   
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>[/tt]

I appreciate any help I can get.  As I said, I'm more a designer than a coder, and it's driving me nuts.

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.