simple php login script
what i'm looking for is a tutorial for a simple user login script
where users can register username/password (probably a simple form for the boxes etc) ,
the script to check the DB for duplicate names, offers another chance to pick another name, or if no dupe then creates the username/passwordentry in the DB table
i have had the php accessing the db and checking tables etc
thats not really a problem. the problem is getting it working on my current site
I have found many tutorials but none of them seem to explain FULLY the workings
out of the 12-15 i have read, they never tell you a typical page layout for each piece of script
i already have a basic site, and am struggling to figure out where all the script goes on each of my current pages
anyone got a link for a real simple beginers tutorial?
thanks

teammatt3 posted this at 00:14 — 23rd April 2007.
He has: 2,102 posts
Joined: Sep 2003
I don't have a simple tutorial for you, but if you're serious about learning PHP and MySQL, I recommend the book PHP and MySQL for Dynamic Websites. I have the first edition and I finally buckled down and read it. I learned a ton. Toward the end the author tells you how to do a simple ecommerce site, CMS (which includes registration) and another thing (I can't remember what it was). You might even be able to find it at a library.
greg posted this at 06:20 — 23rd April 2007.
He has: 1,581 posts
Joined: Nov 2005
thanks for the advice!
I will shortly be learning PHP in a more in depth approach
but for now, i just need to get a login script working on my current site.
once that's in place i can sit back a bit and have some time to look at the ins and outs of PHP a bit more
cheers
kb posted this at 06:59 — 23rd April 2007.
He has: 1,380 posts
Joined: Feb 2002
To be honest, a login script being written for you isn't going to do much for you...what kind of things are you going to do for your 'members'? Serve them static content? The point of being a member or 'logging in' to somewhere is that the page is then personalized according to your needs and preferences... you can't do that without scripting.
Try hotscripts.com, or Google it. There a million pre-written ways to do what you want. But I, along with everyone else, think you should take the time to learn...then your site will have that customized feel.
I was once in your shoes, looking for a 'login script'...and I ended up having someone write one for me, but it got me nowhere. After I realized that, I sat down and read books from SitePoint.com, and articles all over the place...at this point I'm very good with PHP (but by no means an expert).
One of your best resources can be the online docs at PHP.net
greg posted this at 14:00 — 1st May 2007.
He has: 1,581 posts
Joined: Nov 2005
ok thanks for the tips
I am back to messing with php to try and get it working myself. (phew)
one thing I am stuck with
the code that connects to the DB and the 'session_start();' code, if I put that in the home page what if the user has bookmarked the products page and returns one day but doesnt go to the homepage? those commands are not executed and the products page doesn't work as the DB hasn't been accessed!
I have a header page, which is the site nav links, logo etc, that is included in EVERY page, but if I put the (above) code in there, whenever I go through the site to another page it returns an error that the DB has already been accessed and the session_start cannot be done twice.
any ideas/thoughts on a resolve for this?
much appreciated
mmoglobal posted this at 23:31 — 1st May 2007.
They have: 11 posts
Joined: May 2007
if included header pages with session_start() on pages with user defined dynamic content. dont eliminate the problems, you can try something like
if (isset($_SESSION['%var%'])) {
$username = $_SESSION['%var%'];
} else {
Header ("Location:http://www.yoursite.com/yourpage.ext");
}
which will redirect the person to a page where the session_start() code is.
there are many more defined methods of doing this, these are just simple examples.
mmoGlobal - MMORPG Gaming Networks
greg posted this at 10:22 — 2nd May 2007.
He has: 1,581 posts
Joined: Nov 2005
thanks for the redirector tip
but I wouldnt want to redirect soemone from a page they bookmarked, they might think the website isnt very good or I have somehow messed with their bookmarks
even without them thinking that, I wouldnt want to remove customers bookmark functionality
and the other problem i see with that code is what if the user hasn't logged on, and just wants to browse the packages?
thanks, but there must be a simple way to work around this.
There must be even a 'run once' type command or similiar I could use, where it would check if session is started and if so not to try and start it again, as with connecting to the DB, only if it hasnt already been done
I will continue to search the net (groan)
greg posted this at 15:53 — 7th May 2007.
He has: 1,581 posts
Joined: Nov 2005
ok solved it.
incase it helps anyone else...
I was including my "header.php" page within , and the session_start() is in that header.php (so i dont have to include it in all pages) so effectively was called after html
:flame: PHP

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.