Skip navigation
Berurier75
Currently Being Moderated

[CS4] Post login problem

Mar 8, 2013 5:28 AM

Hi everybody,

I’m facing a problem I can’t solve as I’m not an expert with php : I have created a site of which first page is a login. On the second page I would like to retrieve informations from a database based on the logged on user ID. Here is the problem : I don’t know how I can insert the user ID on the SQL request (on page 2). I’ve tried to put as Run-Time value of my Recordset template $_GET[‘MM_Username’] but it does not work. Creating a session value into the bindings panel allows me to display the correct ID value (therefore MM_Username) on the HTML page but still I can’t do anything with it into my SQL request… I’m lost !

Thanks in advance for your help/advices

Best regards

 
Replies
  • Currently Being Moderated
    Mar 8, 2013 6:06 AM   in reply to Berurier75

    can you post your SQL query for us to see?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2013 7:25 AM   in reply to Berurier75

    $query_Recordset1 = sprintf("SELECT repertoire.identifiant, repertoire.raison_soc FROM repertoire WHERE repertoire.identifiant=%s", GetSQLValueString($IDCourtier_Recordset1, "text"));

    Start with a nice simple query and build it up from there!

     

    $query_Recordset1 = ("SELECT * FROM repertoire WHERE identifiant = '$IDCourtier_Recordset1'");

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2013 9:20 AM   in reply to Berurier75

    First, let's see what the login page is doing - can you post that PHP please?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2013 9:45 AM   in reply to Berurier75

    On this page, change this -

     

    $MM_redirectLoginSuccess = "Menu.php";

     

    to this -

     

    $MM_redirectLoginSuccess = "Menu.php?MM_Username=$loginUsername";

     

    and see if that works.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2013 10:35 AM   in reply to Berurier75

    Now you have to explain to us why it works!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2013 11:14 AM   in reply to MurraySummers

    You could have retrieved that session variable on page 2 with some new code, but you already had the mechanisom in place to pass the user name from page 1 to page 2 as a URL variable, so my suggested change simply made the redirection command include the URL variable. As you see that was all that was needed.

     

    To retrieve the session variable, you would need to put this at the very top of page 2 -

     

    if (!isset($_SESSION)) {

     

      session_start();

     

    }

     

    and then you would add this just below that new block -

     

    $IDCourtier_Recordset1 = $_SESSION['MM_Username'];

     

    That should also work instead of passing the user name as a visible URL variable.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points