On Nov 10, 2005, at 7:21 AM, jusa_98@xxxxxxxxx wrote:
Need some ideas/opinions on a project I have.
The project is for a Radio Station (online one) where DJ's can
login to the site and do stuff and listeners can listen in live to
the live feeds.
Now I downloaded a password protected code that uses MySQL to store
the info but it fails each time. It wont sucessfully login despite
setting the database up correctly etc. So instead of posting the
code here I would like to know peoples ideas/links on a method of
login. What I'd prefer to set is not a HTML login but more the
traditional popup box login. Like used on CPANEL. The username/
password (details) will be stored to a database. Any suggestions
on fully working code?
If it's failing all the time I do suspect you don't have it set up
correctly but never mind.
The good news is what you want is pretty straight forward. You will
set up a table in your DB I've called it 'Person' and it has the
login_name and login_password fields (I'm sure you'll want it to have
other fields too but these are the only ones you need to login).
Now in PHP you will make the browser display the login box by sending
it the 401 header; you must do this first before you send any text.
Now the browser will send the name and password every time it tries
to view this page. In PHP you can get the name and passwords in the
server variables $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']
You run a query to verity this name and password match if so go in
with the page, if not return the 401 again.
I find it's best to put all this in a function and call that function
first on each page you want to be secure. I'll send you a specific
example but it's a bit long to post here.
Also each DJ will have a webpage within a database. So updates to
their pages will be made on the database, as I am not really good
at writing to a text file from PHP from a webpage. Never learnt it
to be honest, what would be easiest/best? Writing to a database or
a text file directly?
either way they each have their own advantages; is it harder to say
$link = fopen("bigrick.html", "w");
fwrite($link,$_POST['pageText']);
or
$myQuery = "insert into Page (dj, pageText) values($dj, '" .
mysql_real_escape_string ( POST['pageText'] ) . "');
mysql_query($myQuery);
The real issue here is what is the text you are saving? Are you
expecting the DJ's to write all the HTML themselves? The first
example will require the person entering the form to enter all of
the HTML tags; the second example you could put the text between
the <body> </body> tags and maybe you could have some unifying style
items on the top and bottom of the page. This would give you some
unity of style across the DJ pages.
You will also have to deal with the HTML in the text, you can make
carriage returns into <br> or <p> tags but there are dozens of others
you'll have to deal with. But this has nothing to do with where
you store the text - in a file or the DB.
Now if db I need each dj to have their own page like domain.com/djs/
DJNAME.ext ... I know there is a way to get the url written into
the database and not exactly have the file in the www but reads
from the database but I am not sure the PHP/MySQL code to use to
handle it. Any help is mostly appreciated?
How many DJ's are you talking about? And how often do they change?
Our local college station has new DJ's every week.
There are two ways to do this easily. First have a page -
domain.com/djs.php and this will look up the DJ's text if you pass it
in one. So http:// domain.com/djs.php gives you a list of all the
DJ's and http:// domain.com/djs.php?dj=bigrick gives you Big Rick's
page. This is very easy but the URL is a bit awkward to read over
the air.
The other way to do this is to write a special 404 page (this is the
page that gets returned when the server cannot find the page you
asked for) and have this page look at it's url, parse it and figure
out which DJ's page to show. You can also handle other pages that
may not be there (http:/mysql.com/ is like this - type anything after
that URL and it will go to that page if it finds it or it will go to
the generic search page).
You've got a lot of work in front of you, Good Luck,
Frank