Where to go now?
Sorry - I am a PHP newbie.
I have used a login / Logout Script that I obtained from here
I have successfully set up the database and register page. Once my user logs in, the code goes to a page which just says Login Successful. I would like to have it so that the user is immediately redirected to "their" account page to download a spreadsheet that I upload for them each.
Is this a huge thing to get going?
Well lets take a look here.
So you want each individual to get a certain download correct.
1) If you do not currently have an "account page" you can just use the login_success.php as a page for them to download the spreadsheet.
2) On line 36 of login_success.php change
Then simply on that account page have a link to the spreadsheet.
Let me know if this helps.
Excellent thanks Hamburglar - what if I want each individual to go to their "own" page - for example: Client A logs in and sees AccountA.php - Client B logs in and sees AccountB.php and so on...
I had a gut feeling you wanted to do that.
Well if you wanted to display relevant information for each user then you would need to store that information in a database.
So for example, if Hamburglar log's in, he would see a lot of cheese burgers. If Ronald Mcdonald logs in, he would see french fries.
The information pertaining to each user has to stored in the database. So when you I login (Hamburglar) it can access my information.
You do not need to create a page for each user. Just a simple database query that would get relevant information.
What exactly do you want them to do?
is each spreadsheet different for each user?
hehe - yes that's the one lol
I am wanting Mr H to log in then access one page with download links of his invoices and spreadsheet with his data on and Mr B to log in and see his page of download links of invoices and his spreadsheet and so on
Originally Posted by PaulB1974
Now depending on your knowledge of PHP, you can add all this information in the database. This way when Mr H log's in, he can access his invoice. There should be an admin area to upload the invoice as well.
This is the most basic thing I can think of right now. You can name the invoice file like invoice_username.xls
Grab the username from the session variable and place it there.
Code for linking the file
$username = $_SESSION['myusername'];
But if you want them to have access to historic invoices it would be best to use a databse.
<a href="invoice_<? echo $username?>.xls">Download Invoice</a>
Hamburglar - you are very kind - great name too I will have a play with these code snippets and post back
Hamburglar - If I wanted to put everything into the database (I have the upload to database feature) then, after Log In, how would I link to, say, Paul.xlsx in the database? I think I agree, I may do it the database way
What is the table structure for the uploaded files?
Originally Posted by PaulB1974
Is the uploaded part connected with a cartain user? or is it just a simple file upload?
At the moment it is a table called file and is seperate form and is a simple file upload which places the object into the database using BLOB(?)
I got the file upload script from here
both my members table and file table are part of the same database
I would like the uploaded file to be only accessed by a certain user sorry
It is fine if the table is part of the database. However the database needs to have another table that shows the connection. That table in essence will say "This file belongs to Mr H".
Right now, all your database does it upload files and users. There is no table in your database that links them together. That is what you will need to create.
Now the currently upload file script you are using will need to be modified on 3 levels.
1) Database Table
The table 'file' will need another column that says user_id. This says "File XYZ belongs to this user_id".
2) Admin area.
When you add a file, you will need a drop down or select box that will grab the user_id and attach it to that file.
So for example:
a) You select excelt invoice
b) from drop down you select mr H
c) info gets added into database
3) User interface
When the user logs in, they can access their file by just querying the database. Nothing else to it.
If you are having trouble, I can whip up a script for you tomorrow sometime.
Mr H - I am overcome with your kindness thank you so much - I understand what you have said and I will try and do this myself and let you know
Thanks so much again!
Ah lol - failed at the first hurdle! Added the Column User_ID then went to add a dropdown but then I don't know how to add the list in the dropdown LOL
I have got a For Dummies PHP & MySQL book here, maybe I should read it!! /
You might want to look at some other books as well since Dummies books are like trying to learn how to swim while being in a puddle.
PHP and MySQL Web Development by Luke Welling and Laura Thomson
Murach's PHP and MySQL by Joel Murach and Ray Harris
Beginning PHP and MySQL: From Novice to Professional by W. Jason Gilmore
I have used the first one. I have used Murach's books for Java and tend to be more about making an application and learning bits along the way. apress puts out solid books overall so they get a mention as well.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)