www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: Where to go now?

  1. #1
    Join Date
    Dec 2011
    Posts
    27

    Where to go now?

    Hello all

    Sorry - I am a PHP newbie.

    I have used a login / Logout Script that I obtained from here

    http://phpeasystep.com/phptu/6.html

    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?

    Thanks

    Paul

  2. #2
    Join Date
    Dec 2011
    Posts
    87
    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
    PHP Code:
    header("location:[B]login_success.php[/B]"); 
    to
    PHP Code:
    header("location:[B]your_account_page_name.php[/B]"); 
    Then simply on that account page have a link to the spreadsheet.

    Let me know if this helps.

    Regards,
    H

  3. #3
    Join Date
    Dec 2011
    Posts
    27
    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...

  4. #4
    Join Date
    Dec 2011
    Posts
    87
    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?

  5. #5
    Join Date
    Dec 2011
    Posts
    27
    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

  6. #6
    Join Date
    Dec 2011
    Posts
    87
    Quote Originally Posted by PaulB1974 View Post
    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
    Option 1:
    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.

    Option 2:
    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.
    PHP Code:
    <?
     $username 
    $_SESSION['myusername'];

    ?>
    Code for linking the file
    PHP Code:
    <a href="invoice_<? echo $username?>.xls">Download Invoice</a>
    But if you want them to have access to historic invoices it would be best to use a databse.

  7. #7
    Join Date
    Dec 2011
    Posts
    27
    Hamburglar - you are very kind - great name too I will have a play with these code snippets and post back

    thanks!

    Paul

  8. #8
    Join Date
    Dec 2011
    Posts
    27
    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

  9. #9
    Join Date
    Dec 2011
    Posts
    87
    Quote Originally Posted by PaulB1974 View Post
    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?

    Is the uploaded part connected with a cartain user? or is it just a simple file upload?

  10. #10
    Join Date
    Dec 2011
    Posts
    27
    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

    http://bytes.com/topic/php/insights/...base-using-php

    both my members table and file table are part of the same database

  11. #11
    Join Date
    Dec 2011
    Posts
    27
    I would like the uploaded file to be only accessed by a certain user sorry

  12. #12
    Join Date
    Dec 2011
    Posts
    87
    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.

    Regards,
    H

  13. #13
    Join Date
    Dec 2011
    Posts
    27
    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!

  14. #14
    Join Date
    Dec 2011
    Posts
    27
    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!! /

  15. #15
    Join Date
    Nov 2002
    Posts
    2,632
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles