|
-
May 5th, 2013, 07:08 PM
#1
Thread Starter
Junior Member
using php to create an ask the trainer page
first, allow me to thank all of you for your help in creating this website. now, i am trying to get one last bug worked out before going live. i have a subscription site that gives users a year access to training videos and an ask the trainer section. i have it all done except for the q & a page. i have read php tutorials and have the basics down, as far as using an sql database to store the comments and am having one small problem. i want anyone to be able to ask a question and only the trainer can answer. i have been looking at a lot of source code for a lot of sites, but i cannot figure out how to implement that only he has access to answer each question. i may have to create a page just for him when he logs in so that he gets the option to answer each question. using a script to have anyone leave comments is easy, i got tons of free scripts to use, but the answer thing is a real pain. thanx for any help.
< advertising link removed by moderator >
-
May 6th, 2013, 02:16 AM
#2
Hyperactive Member
Re: using php to create an ask the trainer page
I'm assuming members have to log in.
if you are keeping member's accounts in a SQL database then add a field for "Is this a moderator?"
then, when outputing the page, have the php call the SQL and check the "Is this a moderator?"
if it is, then show the answer form.
if it's not, then skip the answer form.
This method will allow you to have any number of moderators.
you can make the field default to a "Not a moderator" value and edit that value for only the moderators you intend to allow to answer questions.
for example, in theory, (and psudo-code)
example table
Code:
ID as Integer | Username As Char | Password as MD5 | IsMod as Char
-------------------------------------------------------------------
1 | Bob | MyPassword | No
2 | Bill | HisPassword | No
3 | Linda | HerPassword | YES
4 | Jack | Another Pass | YES
example php
Code:
<?php
display question page....
SQL Query "select IsMod From MyUsersTable where UserName = LoginName"
if (IsMod == "YES")
{
echo <answer form> at bottom of page
}
Linda and Jack can see the answer form. the other people never get the form section of the page.
It's hard to be more specific (code wise) without more detailed information on your site's code.
Last edited by Waxy; May 6th, 2013 at 02:22 AM.
----------------------------------------------------
Missing the days of GWBasic 1.1
WaxyStudios.com
-
May 6th, 2013, 08:58 AM
#3
Thread Starter
Junior Member
Re: using php to create an ask the trainer page
that sounds like the best answer. i don't have the code yet, i was trying to work out the problem first so that i didn't have to scrap anything i wrote and start over. this helps a lot and thank you very much for the tip
< advertising link removed by moderator >
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|