Jump to content

Recommended Posts

Could you post your code?

 

All you would do for that is on the page where the POST data is sent to, you would just check it against the database.

 

So lets say this is the page that they are taken to after they supply their login name and password.

 

<?php

//get their supplied login and pass
$login = $_POST['login'];
$pass = $_POST['password'];

//See if they match the database
$query = mysql_query("SELECT count(*) FROM users WHERE login='$login' AND password='$pass'") or die (mysql_error());

if (mysql_num_rows($query) > 0){
  //login correct, register their session here.

} else {
   //WRONG login/pass combo....deny them.
}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/55854-checking-passwords/#findComment-275931
Share on other sites

where should i put the correct usernames and passwords in the code?

 

Well...if the information they logged in with is correct, then the variables $login and $pass will hold the correct username and password.

 

I'm not exactly sure what you mean though...

Link to comment
https://forums.phpfreaks.com/topic/55854-checking-passwords/#findComment-275935
Share on other sites

Could you be more specific? Use an if statement for what? I don't know exactly what your trying to figure out now.

 

Are you wondering how to create a session that holds a unique ID that will tie to that user in the database so you can call their information on other pages?

Link to comment
https://forums.phpfreaks.com/topic/55854-checking-passwords/#findComment-275940
Share on other sites

<?php

//get their supplied login and pass
$login = $_POST['login'];
$pass = $_POST['password'];

//See if they match the database
$query = mysql_query("SELECT count(*) FROM users WHERE login='$login' AND password='$pass'") or die (mysql_error());

if (mysql_num_rows($query) > 0){

header("Location: http://www.url.com/"); //<-----This is where you are redirecting them to.

//Your going to want to register a session or cookie here to finish the login process.

} else {
   //WRONG login/pass combo....deny them.
}

?>

 

I added it for you. Just replace the url in the code to where you want the script to take them too if they have the right login info.

Link to comment
https://forums.phpfreaks.com/topic/55854-checking-passwords/#findComment-275947
Share on other sites

Oh, I see what you are saying. You have to store them in a database. If you have a hosting plan, chances are that they have a control panel where you have access to creating your own database.

 

I would suggest learning the basics of PHP and databases before taking on a project like this one.

Link to comment
https://forums.phpfreaks.com/topic/55854-checking-passwords/#findComment-275952
Share on other sites

Is this a type of website where many different users with different logins and passwords are being used?

 

If it isn't, and there will always only be one username, and one password...then you don't need a database. You didn't really explain exactly what you were trying to do.

Link to comment
https://forums.phpfreaks.com/topic/55854-checking-passwords/#findComment-275953
Share on other sites

If you do that, you won't be able to have the 30 or so users you were talking about. Unless everyone used the same exact username and password. You wouldn't be able to differentiate who was who.

 

There are plenty of tutorials out there for login scripts.

http://www.google.com/search?hl=en&q=PHP+login+script+tutorial&btnG=Search

 

 

Link to comment
https://forums.phpfreaks.com/topic/55854-checking-passwords/#findComment-275966
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.