Closed Thread Icon

Topic awaiting preservation: Unique User Logins Using PHP/MySQL (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23690" title="Pages that link to Topic awaiting preservation: Unique User Logins Using PHP/MySQL (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Unique User Logins Using PHP/MySQL <span class="small">(Page 1 of 1)</span>\

 
Jimmy
Nervous Wreck (II) Inmate

From: Alderaan
Insane since: Sep 2004

posted posted 10-17-2004 20:53

I'm looking to create a login system, using PHP & MySQL, to limit which sections of my site certain people have access to. I realize this can be done in other ways but for the sake of learning I'd like to use PHP & MySQL.

My original plan of action was to check if a person was logged in via cookies. If not, they would be redirected to a log in page, where after logging in they'd be redirected back. If they were logged in I would check if they have access to the particular page, for example my add a link page. If they have access, I display a form to add the link. If they do not, a statement saying they do not have access is displayed.

I'm having lots of problems but I think my biggest problem right now is the redirect. I searched the Asylum & the FAQs and found info on PHP redirects. As far as I can tell though, it only works in the header and not in the body. Is it possible to create a script that redirects based on a condition in the body? If anyone can point me in a directioin I'd be very thankful.

Jim

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 10-18-2004 02:40

So your question boils down to where you can do your redirect? If you have more questions than that please ask again.

As for your redirect issue. Using PHP your redirect HAS to be in the head section. What this means is you have to put the redirect code as the first bit of code.

code:
<?php header('location:thepage'); ?>
<html>
<head>
<title></title>
<body>
</body>
</html>



If you are having problems figuiring out how to make this work in your script then you might need to reexamine how you code. If this is an access issue and for some ungodly reason you can't put your PHP code at the top of the page, such as constrains of a CMS or some other stuff that the server exports, then you are out of luck.

However, baring the above cases, which I don't think would apply. You can easily design your script so that the main portion of your code is held in the top.

The basic concept here is that you do all the processing at the top of your page, and then assign values you will want to output to the page into variable. Then, wherever you need to output some kind of data you output the information that is stored in the variables only, and you do no data processing outside of your top php code block.

Make sense? If not let me know what doens't and I am sure it will get clarified.

Dan @ Code Town

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 10-18-2004 10:16

Slightly off topic: is there anyway to do a php redirect similar to a meta tag redirect which does after a few seconds? My concern is using the meta redirect as search engines dont like it.

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-18-2004 10:25

the How can I redirect a page with PHP? faq describes both ways to do a php redirect.
edit: (and php correctly set's the response header to 3xx as well)

(Edited by Tyberius Prime on 10-18-2004 10:26)

Jimmy
Nervous Wreck (II) Inmate

From: Alderaan
Insane since: Sep 2004

posted posted 10-20-2004 03:51

Thanks Dan, I think I get exactly what you're saying. I'll play around with it and see what happens.

=)

Jim

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 10-20-2004 10:34

thanks tyb, wasnt sure u could do that. Any idea if search engines have problems with this like meta tags? I wouldnt think so since its server side...

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-20-2004 13:43

any search crawler that does not follow 3xx header-redirects is broken.

And I know google follows them, that's how the asylum migrated to the new url sheme. (and google now only finds the new urls)

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 10-20-2004 16:53

sounds good, thanks for that!

« BackwardsOnwards »

Show Forum Drop Down Menu