Re: [PHP-DB] Login Auth help? | Handling pages help? (2 questions)

2005-11-13 Thread Frank Flynn


On Nov 10, 2005, at 7:21 AM, [EMAIL PROTECTED] 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



[PHP-DB] Re: Would you look at some code?

2005-11-13 Thread Ajree

Ron Piggott wrote:

I am getting the parse error message

Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or
'$' line 121


(...)


++ii;
}

++i;
}
?


Shouldn't you write:

++$ii;
}

++$i;
}
?

:) ? It's the variable sign '$' what is missing here.

--
Ajree

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: Would you look at some code?

2005-11-13 Thread Ron Piggott
Thanks.  I didn't understand what this error message was saying to me.
Ron

On Sun, 2005-13-11 at 18:20 -0500, Ron Piggott wrote:
 I am getting the parse error message
 
 Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or
 '$' line 121

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] HTTP Auth help required, please?

2005-11-13 Thread JeRRy
Hi,
 
I am having HUGE problems with the following:
 
HTTP Auth in the latest version of PHP.
 
Usernames are saved to a db but even when you enter a correct combination it 
fails.  So I think it is best to start from scratch and try and get some code 
from people that are using the latest version of PHP.  I am aware that there 
was huge problems with release 5.0 regarding this issue but when I put the 
updated code it it still fails.
 
So can someone provide me with the code I need.    So i can try and let you 
know how I go.
 
What I need is: 
- PHP Code to input into my file.php file.  (this code should include an error 
message if a bad user/pass is entered and a sucessful message, or a redirect 
url code. User / Password is stored to a db, db_name preferable is users
- PHP code should include the connection to the db also, saves me editing it 
later.
 
I have already setup a database already with the last code I have.  So if the 
query needs editing I can do this.  I just need something that works, and 
basic!  I have been trying to get this to work for ages.
 
Please provide two login methods, than I can test both.  Maybe it's the method 
of login that is causing me grief.
 
- HTTP popup box
- HTTP web-form
 
I have only tried the popup box method, never been able to get sucessfully 
logged in.  Not tried the web-form method yet.  If someone could whiz up some 
code for me or direct me to a url I can try and post back with the error I am 
getting.
 
Thanks!
 
Jerry


-
Do you Yahoo!?
  Yahoo! Photos: Now with unlimited storage

[PHP-DB] HTTP Auth help required, please?

2005-11-13 Thread JeRRy
Hi,
 
I am having HUGE problems with the following:
 
HTTP Auth in the latest version of PHP.
 
Usernames are saved to a db but even when you enter a correct combination it 
fails.  So I think it is best to start from scratch and try and get some code 
from people that are using the latest version of PHP.  I am aware that there 
was huge problems with release 5.0 regarding this issue but when I put the 
updated code it it still fails.
 
So can someone provide me with the code I need.    So i can try and let you 
know how I go.
 
What I need is: 
- PHP Code to input into my file.php file.  (this code should include an error 
message if a bad user/pass is entered and a sucessful message, or a redirect 
url code. User / Password is stored to a db, db_name preferable is users
- PHP code should include the connection to the db also, saves me editing it 
later.
 
I have already setup a database already with the last code I have.  So if the 
query needs editing I can do this.  I just need something that works, and 
basic!  I have been trying to get this to work for ages.
 
Please provide two login methods, than I can test both.  Maybe it's the method 
of login that is causing me grief.
 
- HTTP popup box
- HTTP web-form
 
I have only tried the popup box method, never been able to get sucessfully 
logged in.  Not tried the web-form method yet.  If someone could whiz up some 
code for me or direct me to a url I can try and post back with the error I am 
getting.
 
Thanks!
 
Jerry


-
Do you Yahoo!?
  Listen to over 20 online radio stations and watch over 5000 music videos on 
Yahoo! Music.