Jump to content

Recommended Posts

I have about 50 folders for 50 different clients that access these folders from seperate links. so basically customer "joe smith" will go to www.mywebsite.com/Jsmith

 

and enter his password

 

is there a way i can create a user name and login in www.mywebsite.com so when the user enters the correct name and password it will direct him to the correct folder instead of me sending out 50 different links, it would be easier to just have 1 link

 

thank you in advance

 

Matt

Link to comment
https://forums.phpfreaks.com/topic/136218-listing-filesphp-made-easier/
Share on other sites

Yep, there are alot of ways. MySQL db is probably the most common and secureist. You could even have a text file of username:password / linktoredirect and just put each new user on a different and hash the password. This is the unsafeway as anyone could potentially read the file unless it is put in the right spot.

 

You could even just hardcode the username/passwords on the php page in a multi-dimm array like this:

 

$usersPass = array(array("username" => "jack", "password" => "md5hash of password", "redirect" => "urltoredirecto"), array("username" => "john", "password" => "md5hash of password", "redirect" => "urltoredirecto"));

foreach ($usersPass as $userArr) {
     if ($userArr['username'] == $_POST['username'] && $userArr['password'] == md5($_POST['password']))
             header("location: " . $userArr['redirect']);
}

 

It just depends on how secure you want it. My preference, MySQL.

ps. Im living in germany at the moment, but im actually from west chester pa right near philadelphia about 30 miles, small world

 

That's funny, I go to West Chester University.  Very small world...

 

Example (*not tested):

 

if(isset($_POST['submit']))
{
  $username = $_POST['username'];
  header( 'Location: http://www.mywebsite.com/$username' ) ;
}
?>

</pre>
<form method="post" action="<?php%20%24_SERVER%5B'PHP_SELF'%5D;%20?>><br%20/>%0A<input%20type=" text name="username">


</form>
<b

 

 

So, in essence, whatever they type in for their user name is going to be what folder they're redirected to.  Best way to do this is the use of a DB.  Of course you need to validate, error check, check passwords etc. but this should give you an idea.

thanks guys.... I still dont fully understand because my iq is 50. So i create a user name and password on a php page and when I login I just add this code to the page?

 

I took a few classes at west chester, I took java there... since i failed java 2 times at albright I took it at west chester and got a b- ... we didnt have to hand write the code at wc... it was sweet... my teacher was asian .. you had thet guy?

 

Matt

 

ps whered you go to high school?

I still dont fully understand because my iq is 50.

 

Bummer...

 

So i create a user name and password on a php page and when I login I just add this code to the page?

 

How do you check the user name/password in the first place?

 

we didnt have to hand write the code at wc... it was sweet... my teacher was asian .. you had thet guy?

 

Hand write code...  :o  The only hand-written code were on exams.  There are a lot of asian teachers, I've had a couple, do you remember his name? 

 

ps whered you go to high school?

 

Penncrest

 

 

I can not remember his name... All i remember is he was asian and he taught java 101

O yeah i know penncrest, I went to malvern.. small world

 

the user name and password are checked in my index.php file

you can grab the file here if youd like

 

http://www.evoluted.net/community/code/directorylisting.php

 

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.