Need help with log-in...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bogey
Forum Commoner
Posts: 34
Joined: Sat Nov 10, 2007 5:51 pm

Need help with log-in...

Post by Bogey »

I have a registration form that when submitted into the database encrypts the name and username submitted... the code for encryption I use is...

Code: Select all

//Encrypting function
function Encrypt($string) {//hash then encrypt a string
$crypted = crypt(md5($string), md5($string));
return $crypted;
}
//Encrypting the password and username
 $password = encrypt($password);
 $name = encrypt($username);
I'm telling that for the info that I would need in creating the log-in script... but I might simple change that encryption just to md5($username); and nothing else... I need help on this... any help would be greatly appreciated.

I have a very basic idea on what I would need... I mean VERY basic like only the thoughts of what Ineed but have no idea how to do it... what I want is something like this...

A log-in where a user submits a Name and a password which is than encrypted and than the other password and name are taken from the database (which are encrypted the same way) and then the name and password to be checked if they are the same, and if they are then they are logged in and if they are not the same then the user is not logged in and gets an error...

If the user is logged in then a session cookie is created holding the following values...

Name
User id
member-level (as in administrator or member)
Logged-in (verifies that the user is logged in)

And if I want to post the user's name on a page (if they are logged in) the could would look something like the following...

Code: Select all

echo $session->$name;
(I think thats what it would be... I'm just learning PHP) and to make certain features available to members it would be something like...

Code: Select all

<?php
  if($session->member) {
?>
Members only words
<?php
 } else {
?>
Nonmembers words
<?php
 }
?>
Is that right? or would it be something else? I need a lot of help on this...

The questions I have is...
  1. How do I make a session cookies holding all of that submitted info?
    How do I make the session cookie go from page to page (or each page having access to that cookie... I don't want the cookie info to be stored in the url).
I know I would need the member level (if it's the admin or just a member) to be stored in the database and when the user logs in than the script takes that from the database and stores it in a cookie... (but that value still stays in the database of course :) )

I think I made myself clear on this... I need help with all of that... how do I do all of that?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

You are covering a lot of ground there. I would recommend starting at the beginning with the form that submits the username and password. Do you have that to show us? Then we can deal with sorting out the Request and then move on to the other stuff you mention.
(#10850)
Bogey
Forum Commoner
Posts: 34
Joined: Sat Nov 10, 2007 5:51 pm

Post by Bogey »

Okay, I have a full registration form written which submits data into a database... to see a working version of it... try the following link

(sorry, I'm trying to prevent showing the full code, but I probably will if it would help you help me get a log-in that actually works the way I want it to).

http://bogs.pcriot.com/registration/register.php

[edit]
The captcha doesn't work at the moment so you obviously can't register as a test or whatever...
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

It would be helpful to either produce a simplified version of your code that we can look at or post the whole thing. What is the specific problem?
(#10850)
Post Reply