Question:
php/mysql question?
anonymous
2007-03-13 06:54:14 UTC
I am a beginner @ this but when i am finished w/ this i would like a user name and password on my index page with the option to create an account as well

so i have the table done if they want to create the account
the only question i have on this is when i ask for password and re enter password and then email and re enter email how do i make sure these equal eachother

once they equal each other

how do i get an email to them with thier account details and make sure they verify the account?

after the account is verified i would like them to be able to login

so for the login do i need another table? is there a template for this type of thing

where are username and passwords stored is that in a seperate table and when a username and password is typed in it pulls thier account up from the other table??

i need help with this
so plz help:)
Three answers:
apeware
2007-03-13 10:17:17 UTC
This may or may not be overkill for your project, but there is a really nice system that works out of the box (free) on evolt.org. The v2 of the secure login system with admin functions, has everything you are looking for and even comes with example code. Use what you want and leave out what you don't need. The classes are built very well and would require minimal editing to get it working. If the above answers don't do it for you, give the example on evolt.org a shot. If nothing else, if you can learn from the examples and detailed explanation. Good luck!
anonymous
2007-03-13 07:54:19 UTC
"how do i make sure these equal eachother"



Use JavaScript to compare the values of the two password boxes.



"so for the login do i need another table? is there a template for this type of thing"



You need a table like this:



Users(username, password, role, blah, yada, ...)



username being the primary key.



"where are username and passwords stored is that in a seperate table and when a username and password is typed in it pulls thier account up from the other table??"



It is stored in the Users table and it should be stored encrypted with an algorithm like SHA or MD5. Any other account info can be stored in other tables with username being the foreign key. This is a DB design issue and you need to learn how to do it.



When you run the PHP that processes the login, it should take the typed in password from the page and encrypt it BEFORE checking it against the DB password.



Once they login, you can set a session variable named maybe "auth" and for every page that you need to be logged in for, you check if auth is "true". If not you redirect to the login page or say "you need to be logged in for this."



Sorry to break it to you but this isn't a 10-minute task. Go pick up a PHP book and it will tell you more.
Alex
2007-03-13 07:46:44 UTC
It sounds like you're in a little over your head on this one!



When somebody tries to create a new account, they should submit a form when they hit the "submit" button. When you are reading the POST data in PHP (I assume you're doing this in PHP?) you should compare the two values in an "if statement":



if($password1 != $password2)

$validEmail = 0;



To send mail in PHP, use

mail($to, $subject, $body)

but you should check to make sure it goes through! A good little sample is here:

http://email.about.com/cs/phpemailtips/qt/et031202.htm



Logging in is more complex. You're going to have to learn how to use something called sessions to do that. Start here:

http://us2.php.net/session



There are two types of tables, and I'm not sure if you mean a MySQL table or an HTML table. When someone creates their account, you should store their username and ENCRYPTED password into a MySQL table. For encryption, use SHA().



If I have a MySQL table, 'users', with two columns: 'username' and 'password', I would do:



INSERT INTO users (username, password) VALUES ("$username", SHA("$password"))



When someone logs in, you want to run a SELECT query on the users table, where you compare both usernames and the SHA'd password to the value in your password column.



It really does sound like you could use some outside help on this, though.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...