Jump to content

Recommended Posts

Hi i am having some problems with this code my $loginUsername is suppose to link the username entered to the account or welcome page if login success but it doesnt.It takes all of the success login to a particular page instead of indivduals pages.

Helpppppp.

if (isset($_POST['Customer_Number'])) {
  $loginUsername=$_POST['Customer_Number'];
  $password=$_POST['Sort_Code'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "welcome to.php";
  $MM_redirectLoginFailed = "You are not logged in.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_ellen, $ellen);
  
  $LoginRS__query=sprintf("SELECT `Customer Number`, `Sort Code` FROM log WHERE `Customer Number`=%s AND `Sort Code`=%s",
    GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "-1")); 
   
  $LoginRS = mysql_query($LoginRS__query, $ellen) 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 );
  }
}

Link to comment
https://forums.phpfreaks.com/topic/157112-solved-help-needed/
Share on other sites

First, why is there a space in this:

$MM_redirectLoginSuccess = "welcome to.php";

 

Additionally, change the following:

if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }

 

to this:

if (isset($_SESSION['PrevUrl'])) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }

Link to comment
https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827712
Share on other sites

The script you have will redirect to $MM_redirectLoginSuccess = "welcome to.php" if they are a valid user, or to $MM_redirectLoginSuccess = $_SESSION['PrevUrl'], which I'm assuming is the previous URL. You have to change the value of $MM_redirectLoginSuccess for each user based on who they login as. What are the page names for each user (you don't have to list them all just as an example)?

Link to comment
https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827750
Share on other sites

The script you have will redirect to $MM_redirectLoginSuccess = "welcome to.php" if they are a valid user, or to $MM_redirectLoginSuccess = $_SESSION['PrevUrl'], which I'm assuming is the previous URL. You have to change the value of $MM_redirectLoginSuccess for each user based on who they login as. What are the page names for each user (you don't have to list them all just as an example)?

 

Ok hv got 2pages e.g profile1 and the 2nd page profile2

 

do i hv to list the pages e.g $MM_redirectLoginSuccess=profile1 and profile2

then i hv to set each value for each login and password?

Link to comment
https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827766
Share on other sites

You'll need to connect the profiles with the users somehow. I notice in the query you draw the customer number, use that.

 

<?php
if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    } else {
      $profile = mysql_fetch_array($LoginRS);
      $MM_redirectLoginSuccess = "profile_" . $profile[0] . ".php";
    }
    header("Location: " . $MM_redirectLoginSuccess );
?>

 

That will redirect people to profile_xx.php with xx begin their customer number.

Link to comment
https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827805
Share on other sites

Hi thank you,i want to use the login id do i have to define the login id for each user?

for example i have this code it

if (isset($_POST['Login'])) {
  $loginUsername=$_POST['Login'];
  $password=$_POST['Password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "member-profile.php";
  $MM_redirectLoginFailed = "login-failed.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_customer, $customer);
  
  $LoginRS__query=sprintf("SELECT Login, Password FROM log WHERE Login=%s AND Password=%s",
    GetSQLValueString($loginUsername, "int"), GetSQLValueString($password, "int")); 
   
  $LoginRS = mysql_query($LoginRS__query, $customer) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";

 

shud i specify each user login id and password?so that it cud link to each profile?

Link to comment
https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827849
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.