Jump to content


Photo

help with user validation


  • Please log in to reply
7 replies to this topic

#1 chapm4

chapm4
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 February 2006 - 06:22 PM

Please help me before I lose what is left of my mind. I won't put any code here, because mine doesn't work anyway and I would like to satrt from scratch.

A user comes to the main page of the site. They click on customer to go to a customer-login.php page. This page has username and password on it. When they click submit it goes to a page called loginaction.php. This page validates by cookie the username and password. If those are correct the user is taken to their own page such as customerabc.com. They then fill out an order form, click submit and their order is sent through an email to the company for processing.

The company now wants me to convert the site to mysql for obvious reasons.

on my customer-login.php I have two includes....one is to connect to the database and the other is to login to the database. Both of these work fine. I have one table so far which is called login - it contains the fields username, password, lastLogin, loginId. I set up a page where I pull the data out of those fields and again it works fine. The problem comes when I try to validate that the user that has just entered their information onto the customer-login.php page. I cannot get anything I try to work.

Again, I want the user to enter username and password, these to be validated with the database, and if correct the user will go to their own customer page. What seems like it should be so easy has given me hours of grief. I have used other peoples code snippets as well as writing my own. Can someone please help me accomplish this task where it works? Thank you.....

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 05 February 2006 - 09:02 PM

I'm not really sure I understand what you want help with -- you validate a user/pass pair against a users table, and then find that user_id in the customers table, and take them to a customers page with their info loaded. Where exactly are you running into trouble?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 chapm4

chapm4
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 February 2006 - 03:39 AM

Sorry if I didn't make it very clear.

I successfully log into the database with my new include files. I have the old username and password login page (from the old pre-database site) but don't know how to convert that to validate the user in my new sql table (called login). The old site then went to a certain page based on that user. I don't know how to do this in php/mysql.

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 06 February 2006 - 04:54 AM

Again, same question -- is the problem validating the user/pass against the table, or redirecting the validated user to a specific page? I don't see what the old system has to do with this.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 chapm4

chapm4
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 February 2006 - 01:26 PM

Yes to both things you have said. When I try to validate the user against what is in the database I get a blank page, so I need help with that (I thought it would be better if you helped me from scratch on that page). To validate a user against a database.

And yes to the second part. After I validate the user logging in against the database, I have no idea how to send that user to a specific page based on that user (such as customerA.psp or customerB.psp).

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 06 February 2006 - 07:49 PM

I'm confused -- a blank page? What did you ask it to do? And you can redirect using PHP's redirect function.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 chapm4

chapm4
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 February 2006 - 07:57 PM

[!--quoteo(post=343201:date=Feb 6 2006, 07:49 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Feb 6 2006, 07:49 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I'm confused -- a blank page? What did you ask it to do? And you can redirect using PHP's redirect function.
[/quote]

What I am really asking is for is a tutorial (I can't find one) on the following:
A user comes to the site.
They enter a username and password
The username and password is validated against the login table in mysql
The user is taken to their own individual page with custom graphics and such


#8 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 06 February 2006 - 09:10 PM

I don't know of any particular tutorial.

Like I said, you have the user/pass, simple query the users table, and see if you find a matching record or not, and login them in appropriately.

When you say "individual" page, I think you mean a template page that pulls user-specific info from the DB. Again, easily accomplished with PHP, but I can't think of a tutorial off-hand that would serve a good starting point.

Good luck.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users