Jump to content

Client Login


gillmich

Recommended Posts

I feel like I was 75% there, and now I'm only 25% there.

I'm trying to put my links onto my page. http://thingsihateaboutyou.net/michelle is my testing page.

 

So I have register (register.php), login (login.php), logout (logout.php), and the members area. The members area is going to be their username.php, so I assumed this would be $username.php like I have it in the redirect link from the point where you login to the point where you see your client page. This works fine.

 

The part I'm having trouble with is the visibility of the links on my page to these, AND adding a PHP variable ($username) into the "members area" tag. When you click on members area, it should send you to http://thingsihateaboutyou.net/michelle/*whatever you are logged in as*.php

 

As for the visibility, if you are not logged in I obviously don't want you to see a link called "log out" or a link called "members area," and vise versa. It's been like 5 hours now, and I keep getting further and further away. I had to bail on my Wordpress so I don't have a Content Management System in place. All of this DID work and it worked excellent, but after I made the switch earlier today it kind of blew up in my face.

 

I am attaching a ZIP file with everything included... in desperate need of an answer.

 

[attachment deleted by admin]

Link to comment
Share on other sites

No, I was just saying I've stopped editing the index then and there. That's why it may looked mangled or is showing errors. I was just more or less apologizing for that since I know it's there and just don't know how to fix it, so I wasn't about to make it worse by messing with it more.

Link to comment
Share on other sites

I assume you're setting the username session variable when a user is successfully logged in? But you unset this variable when they are not logged in. If that is the case then you can easily change the visibility of your links with this block of code

<?php if (!isset($_SESSION['username'])):
    display links for users that are not logged in
<?php else: ?>
    display links for users that are logged in
<?php endif; ?>

 

AND adding a PHP variable ($username) into the "members area" tag. When you click on members area, it should send you to http://thingsihateaboutyou.net/michelle/*whatever you are logged in as*.php

So if the user signs in as bob you want the user to go to bob.php? Why are you creating separate php files for each logged in user?

Link to comment
Share on other sites

Because I don't know? The script it is using directs you to a members area but it's the same members area everyone who is logged in sees. the "members.php" is this area, so I just cut that out and rename is /$username.php in the redirect script. Since my "members area" is actually a "client area," I only want them to see what they individually need to see. Should this be different? I am getting the feeling that I'm making this way more complicated than it has to be.

Link to comment
Share on other sites

I assume you're setting the username session variable when a user is successfully logged in? But you unset this variable when they are not logged in. If that is the case then you can easily change the visibility of your links with this block of code

<?php if (!isset($_SESSION['username'])):
    display links for users that are not logged in
<?php else: ?>
    display links for users that are logged in
<?php endif; ?>

 

AND adding a PHP variable ($username) into the "members area" tag. When you click on members area, it should send you to http://thingsihateaboutyou.net/michelle/*whatever you are logged in as*.php

So if the user signs in as bob you want the user to go to bob.php? Why are you creating separate php files for each logged in user?

 

I tried this, and it only displays the links for users who are not logged in, and it displays them whether you're logged in or not. It does not show the other links no matter what.

Link to comment
Share on other sites

I've made great progress with this code:

 

<?php
include 'http://thingsihateaboutyou.net/michelle/membersgear/config/config.php';
session_start();
?>
<?
if (isset($_SESSION['username'])) {?>
<p>Logged as <?echo $_SESSION['username']; ?> | <a href="http://thingsihateaboutyou.net/michelle/membersgear/user_default_page.php">Client Area</a>
| <a href="http://www.thingsihateaboutyou.net/michelle/membersgear/member/user_logout.php">Logout</a> </p>
<? } else {?>
<p> <a href="http://thingsihateaboutyou.net/michelle/membersgear/user_login.php">Login</a>
</p>
<? } ?>

 

My logged in users see their links and my users who are not logged in, do not.

But there is a whole strain of errors just before all the links now.

Link to comment
Share on other sites

Solved it! HAPPY EASTER INDEED!

 

Here is the code for anyone who finds this.

 

<?
if (isset($_SESSION['username'])) {?>
<p>Logged as <?echo $_SESSION['username']; ?> | <a href="http://thingsihateaboutyou.net/michelle/membersgear/user_default_page.php">Client Area</a>
| <a href="http://www.thingsihateaboutyou.net/michelle/membersgear/member/user_logout.php">Logout</a> </p>
<? } else {?>
<p> <a href="http://thingsihateaboutyou.net/michelle/membersgear/user_login.php">Login</a>
</p>
<? } ?>

Link to comment
Share on other sites

Umm.... Isn't that basically the same as the code I posted earlier!

<?php if (!isset($_SESSION['username'])):
    display links for users that are not logged in
<?php else: ?>
    display links for users that are logged in
<?php endif; ?>

 

Did you know includes behave differently when using a url as the path rather than a local file system path.

include 'http://thingsihateaboutyou.net/michelle/membersgear/config/config.php';

If you have variables in config.php that you may want to use in members.php then they won't be accessible. That is because when using a url with incude it will only return the output of that script rather than the source code.

 

Link to comment
Share on other sites

It is, but your code earlier wouldn't work. And actually the "I SOLVED IT" code isn't correct, and I cut out the config because it didn't make sense (my URL's haven't been working on this particular subfolder unless I spell it all out, by the way.)

 

Whatever I did in the index actually DISABLED all my member links. If you want to see what I'm talking about: http://thingsihateaboutyou.net/michelle -- Login produces a blank page, members area, etc. I can't even get into the admin portion of it.

Link to comment
Share on other sites

if you're getting blank pages then you have an error somewhere. Check your servers error log. Or add these lines to the top of your php pages (user_login.php, members.php etc)

<?php error_reporting(E_ALL); 
ini_set('display_errors', 'on'); ?>

 

As for why my code I posted earlier didn't work I forgot to add ?> to the end of this line

<?php if (!isset($_SESSION['username'])):

Link to comment
Share on other sites

I added the ?> to the end of that part, it was actually the rest of the code below that which was reporting errors.

<?php else: ?>

That part reported the first error and it was a domino effect after that.

 

As for the pages, they are still blank. The "support" for the members area (where I got the script) said it could be because my server isn't meeting all the requirements. This can't be because it was working fine before I spent two days messing with my index.php trying to add the links. I didn't alter the other files, in fact I reuploaded them all just to make double sure that they were just the same as when I first uploaded them.

Link to comment
Share on other sites

I basically just verified what I said above. I removed ALL files regarding the members area, then replaced ALL files. They work fine, as before.

As soon as I visited my index.php, ALL files show up blank again.

 

At this point I'm thinking about making it a "Secret" client area. They can guess what the login link is themself!  >:(

Link to comment
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.