Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

once logged in how to direct user to their unique page based on their DB info

Engaged ,
Oct 06, 2011 Oct 06, 2011

ok i have got the user creating a username, password and id. once they logged i want to be able to send them to a page containing information from their inputted information in the database. I was thinking of session varialble to load the information in from the database based on the user id so this is what i done

here is the code

login check page php

<?

$userid=mysql_real_escape_string($userid);

$password=mysql_real_escape_string($password);

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM Hdatabase WHERE userid='$userid' AND password = '$password'"))){

          if(($rec['userid']==$userid)&&($rec['password']==$password)){

           include "include/newsession.php";

            echo "<p class="data"> <center>Successfully,Logged in<br><br><a href='logout.php'> Log OUT </a><br><br><a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";

     print "<script>";

           print " self.location='welcome.php';"; // Comment this line if you don't want to redirect

          print "</script>";

                                        }

                    }

          else {

                    session_unset();

echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct  Userid and Password and Try <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";

          }

?>

this is the newsessions php

<?php

//error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);

$session['id']=session_id();

$session['userid']=$userid;

$session['name']=$name; this is one i have added

//echo $session['userid'];

?>

this is where i though i added new sessions then place them into the welcome page?

add this is a new session i have added from the welcome.php

<?

echo "$session[name]";

?>

i hope you can help

TOPICS
Server side applications
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Oct 06, 2011 Oct 06, 2011

Create a new page with a form and 2 text fields, then go to "Server Behaviours" ==> "User Authentication" ==> "Login User" and follow instructions to create a login page.

Translate
Guest
Oct 06, 2011 Oct 06, 2011

This is how I do it:

  1. Create a page you want the members profile to be displayed on.
  2. Create a recordset using the "simple" mode.

Then use the filter dropdown menu to select the column name "user_email" (Note: The column you are using to store the users email in)

Make it "="

"Session Variable" and in the text field next to this type this: MM_Username

So it should look in the recordset menu sort of like this:

Name:

Recordset Name

Connections:

Table:

Columns:

All Selected

Filter:

Sort:

Then click "OK"

Now make the page restricted. Go to the panel Server Behaviors--> User Authentication--> Restrict Access to Page

And then go to the panel Server Behaviors--> User Authentication--> Log Out User

Next go to the "Bindings Panel" click on the "+"symbol and then highlight the field you want to display. Click the insert button at the bottom of the "Bindings Panel". You can only insert one field at a time.

    

And there you go. A "Profile Page" is created.

For the "Update Page" follow the same steps as above but eliminate the "Bindings Panel" step. Instead use the "Update Record Wizard" to make the profile update page.
(Remember to create the recordset the same as I described above. This is mandatory to for restricted pages to be user profile related)

Explanation of the above process is that when you create a login page with the DreamWeaver function "Log In User", DreamWeaver creates in the code view this:

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

  • So "MM_Username" is needed to be the "Session Variable" in every restricted page that will relate to the logged in user's profile.
  • The page needs to be restricted in order for a "Session Variable" to exist.
  • And of course a "Log Out" button is nice to allow the user to log out.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 06, 2011 Oct 06, 2011

hi, i tried that but it come back with unknown user? should i be rebuilding my who login syste, if i am using the code you provided? will it clash with the code i am currently using? the code above i got from a tutorial. If i scrap this code is there any code out there to make a signup / login / logout / forgot passoword using the way you use?

thanks in advance

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2011 Oct 06, 2011

You should scrap your code and create a login page with the DreamWeaver function "Log In User".

Once you have created the login page then you can use my code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2011 Oct 06, 2011

Create a new page with a form and 2 text fields, then go to "Server Behaviours" ==> "User Authentication" ==> "Login User" and follow instructions to create a login page.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 06, 2011 Oct 06, 2011

ok thanks i will give that a go and see how i get on

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 06, 2011 Oct 06, 2011

thanks very much that seems to have done the trick. once again thanks very much

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 07, 2011 Oct 07, 2011

I'm always happy to help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 30, 2011 Nov 30, 2011
LATEST

hello, i am pulling my hair out on this one. the above code works brilliantly to get information from one table however i wonder if you could help me massivly. i am trying to get information from two tables now,. i have created a join the works when you test it but not when i try and run it. with the above information you provided it give me the following SQL code

SELECT *

FROM tenant_signup

WHERE userid = colname

and the session variable information

but what i need to for the from statement to include

where tenant_signup.prop_id = name_editprop.prop_id

so i have a colum in the tenant_signup called prop_id the matches the name_editprop prop_id

so the from statement would be FROM tenant_signup, name_editprop

currently if i try this it just gives me the information of the forst record of the database

i really hope someone can help

thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines