Search
Left Quote    Black holes are where God divided by zero.
- Steven Wright    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Linking Upload Code With Membership Account
  This user is offline  teachpower
  Subject: "Linking Upload Code With Membership..." Posted: @ 3:06 am on Apr 05 2010   
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

Hello all and thank you bsod for fixing the problem with the CAPTCHA issue.

My site has grown enough and have had many requests for a membership feature on my website so other educators can upload their content to resource library. I luckily found the coding community and incredible membership and upload tutorial here at allsyntax . I have been following both the tutorials and am learning more PHP and SQL because of it. I have a basic understanding of how PHP and SQL works.

My questions is, how do I link the upload code to the membership code so only those that are registered to my site can upload content? I want to be able to offer uploading of education material to those that have already registered and have an account. Can somebody please help me? If you want to see my site to get an idea of what I want... its in my signature. Thanks in advance


Edited at 03:16:29 am on 04/05/10


-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom
    Viewed: 16,268 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Linking Upload Code With Member..." Posted: @ 3:53 am on Apr 05 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA



Edited at 04:01:24 am on 04/05/10


-bs0d | AllSyntax.com

    Viewed: 16,256 Times | Reply to This | To top
  This user is offline  teachpower
  Subject: "re: Linking Upload Code With Member..." Posted: @ 12:40 pm on Apr 05 2010    
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

bsod... First of all I did forget to mention the fact I am also following the "Site Design Made Simple" tutorial. I can have a cleaner more manageable site and I am also guessing a better site to navigate for the user. This site has some great tutorials and community .

Yes I do understand your code piece. My question is can I restrict non-members from viewing certain parts of the page while still showing the rest of the page? FOR EXAMPLE: On the page
http://www.t eachpower.net/L essons/science_ lessons.htm
non-members will be restricted from viewing member feature buttons like "Upload& quot;, "Profile ", etc.?

I just thought of this right now. Would I attach a
<? if($_SESSION[' username'] != "Guest&q uot; die("Memb ers Only"; ?>
to each member only feature button so that if a member clicks on the button it executes that feature (i.e. uploading content), while a non-member would be checked as "Guest&q uot; and be thrown to the login/registrat ion page?



Edited at 01:36:24 pm on 04/05/10


-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom

    Viewed: 16,244 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Linking Upload Code With Member..." Posted: @ 2:10 pm on Apr 05 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Yes, I think you're getting the idea. If you want buttons to appear for members only, then only display them within an IF condition.

<? if($_SESSION[' username'] != "Guest&q uot echo("mem bers ony link"; ?>

*note - you wouldn't use die(); because that will terminate execution of the page, unless of course that's what you want to do.

This way you can display the page, but you're now just specifying some areas or links that will appear for members, but not for guests.

There are multiple ways to authenticate users, like cookies for instance if you didn't want to use session variables. You might read up on that at some point, but this should be enough to get you started.




-bs0d | AllSyntax.com

    Viewed: 16,237 Times | Reply to This | To top
  This user is offline  TeachPower
  Subject: "re: Linking Upload Code With Member..." Posted: @ 2:11 am on Apr 19 2010    
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

bsod... OK I read through the membership tutorial several times and I am understanding what the code is doing. Now where do I put those code pieces? Do I put them all in the <head> part of the webpage?




-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom

    Viewed: 16,170 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Linking Upload Code With Member..." Posted: @ 3:09 am on Apr 19 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Put the code at the beginning of the page_header file, even before <html>.




-bs0d | AllSyntax.com

    Viewed: 16,163 Times | Reply to This | To top
  This user is offline  teachpower
  Subject: "re: Linking Upload Code With Member..." Posted: @ 9:59 pm on Apr 26 2010    
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

OK I am stuck now. I created a membership table with the fields I want and the correct values in phpMyAdmin using XAMPP Now what? Where is this table saved in XAMPP? Is the database a file that I need to put somewhere in my website structure or do I just put the SQL table code to create the table the same place I put the other membership code pieces?




-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom

    Viewed: 16,109 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Linking Upload Code With Member..." Posted: @ 3:29 am on Apr 27 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

You will create the database probably in your hosting control panel if you use a 3rd party for a host. Or are you hosting yourself?

You will use phpMyAdmin to connect to the database and be able to create tables and so on.

The pages you build will allow users to fill out a form to register, and the script behind the scenes will connect to the database and insert the appropriate data in the specified table.




-bs0d | AllSyntax.com

    Viewed: 16,101 Times | Reply to This | To top
  This user is offline  teachpower
  Subject: "re: Linking Upload Code With Member..." Posted: @ 3:49 am on Apr 29 2010    
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

So the SQL database I made in XAMPP with localhost was just for that... localhost? I have to connect to the host (godaddy.com) with myphpAdmin and once I am connected create the database? The database will be its own file in my website structure on the host server? How do I found out how to connect to my host through phpmyAdmin? I am sorry but in this area you can call me a semi-noob.

-TeachPower




-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom

    Viewed: 16,070 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Linking Upload Code With Member..." Posted: @ 5:18 pm on Apr 29 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Login to your hosting control panel @ GoDaddy. There should be an option to create a database, pick a name for it, and setup user accounts with passwords to access it. Once you have that, you can use phpMyAdmin to create the tables. Then when you're creating scripts to interact with the database (read, write, delete, modify), then you need to connect to the database first. You can do that with this code . After that point, your queries should work.




-bs0d | AllSyntax.com

    Viewed: 16,060 Times | Reply to This | To top
  This user is offline  teachpower
  Subject: "re: Linking Upload Code With Member..." Posted: @ 1:48 am on Apr 30 2010    
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

OK I figured out how to and created a database through godaddy. The database is created and I also figured out the variables of dbuser, dname, etc. which I was very confused of what those were when I originally was reading your membership tutorial. My questions now is, if I put that in the webpage code where you told me to put it, can't anybody that views my webpage source online see the username and pass I use to connect to the database and use it to login as me? How can I hide that info in the database connect code?

-TeachPower




-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom

    Viewed: 16,053 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Linking Upload Code With Member..." Posted: @ 2:56 am on Apr 30 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

All of your webpages should now carry the .php extension. This tells the server that the file contains server side code. All PHP code is executed on the server and the result is displayed back to the clients browser. Therefore, the client can never see the PHP code. The database connection is PHP code. As the article indicates, you should have this as a separate file (like: db_connect.php) and include the file like this:

require_once($_ SERVER['DOCUME NT_ROOT'].'/d b_connect.php' );




-bs0d | AllSyntax.com

    Viewed: 16,048 Times | Reply to This | To top
  This user is offline  teachpower
  Subject: "re: Linking Upload Code With Member..." Posted: @ 3:06 pm on Apr 30 2010    
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

Aha got it . I will change all my webpage extensions to .php. I apologize for all these questions in advance but I am greatly appreciative to you that you are helping me and doing it in a very quick response time . I am working on coding the registration and the form that will insert the member which doesn't seem so hard now as I am understanding SQL and PHP the more I use it.

The next question I have is one that I am thinking about that is some steps ahead. My whole goal is to get the member registered and then give the member the feature to upload their own educational content (PowerPoint presentations, Word activity sheets, lesson plans, etc.). Instead of them uploading it to the webpage and then I place it in the page in table format manually as I have done monotonously with my stuff (seen here educational material list ), couldn't I create a field within the member table (TABLE1) that would crossreference another table that contains the educational material the member has uploaded (TABLE2)? Then create a third table (TABLE3) which contains the lesson information on that website link I showed you above. So everytime a member uploads something a new record would be created and displayed in TABLE3 from the info contained in TABLE2? Let's see if I can better explain by diagraming it for you.

DATABASE membership
TABLE1 member
FIELD user
FIELD pass
FIELD email
__ FIELD TABLE2 uploaded_conten t
__ FIELD filename
__ FIELD file_descriptio n
__ FIELD price

TABLE3 webpage_content
FIELD filename
FIELD file_descriptio n
FIELD price
______________ ______________
|``science lessons webpage``|
|..display TABLE3......... ..|

I hope I did a good job of diagraming what I am asking... hehe .



Edited at 03:48:27 pm on 04/30/10


-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom

    Viewed: 16,040 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Linking Upload Code With Member..." Posted: @ 12:31 am on May 01 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

I don't see why you couldn't. If you're looking for a script to allow users to upload files, we have an article on Uploading Image Files with PHP. You could use this script as a baseline and just use different extensions.

Once you're up and running, you'll just have to test your scripts time and time again. Many programmers say they spend more time coding for potential errors than the true intent of the script. This is because anything can trip up your scripts. Define your parameters and box everything basically so you know what you're going to be storing in the database. Also it seems no matter what, some issues develop that you may not have thought of.




-bs0d | AllSyntax.com

    Viewed: 16,031 Times | Reply to This | To top
  This user is offline  teachpower
  Subject: "re: Linking Upload Code With Member..." Posted: @ 9:51 pm on May 28 2010    
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

bsod... been having a hard time setting up the database and fields. When I tried to create a table within a table... or better said a nested table... I am at a loss. I was reading online that nested tables are not able to be created in mySQL? Is that true? If not then how can I make it so that when a member uploads files a table is created specific to him/her that contains all the data in appropriate fields?




-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom

    Viewed: 15,775 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Linking Upload Code With Member..." Posted: @ 2:51 pm on May 29 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

You could just create a field that says image name. When the member uploads the file, store the image name in the members table. Store all user images in the same folder. Then you can display the members image along with the other data very easily.




-bs0d | AllSyntax.com

    Viewed: 15,755 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank