Posts: 1,012
Threads: 94
Joined: May 2011
Reputation:
0
08-12-2011, 09:42 PM
(This post was last modified: 08-12-2011, 09:42 PM by manbat116.)
I don't know much SQL, but why don't you make a variable for the SQL, then check it like:
[lua]
<?php
$okay = TRUE;
$sql = "SQL HERE";
if $sql == "$sql {
$okay = FALSE;
}
?>
[/lua]
That may have errors, I just did it off the top of my head. But it may work.
Posts: 1,725
Threads: 105
Joined: Feb 2011
Reputation:
0
Let me re-state my question.
I have a login system, and for login, how do I check if the input equals the data?
Posts: 1,012
Threads: 94
Joined: May 2011
Reputation:
0
08-13-2011, 04:08 PM
(This post was last modified: 08-13-2011, 05:06 PM by manbat116.)
Oh that's easy!
(password1 is your password, password2 is the one where you confirm it)
[lua]
if($password1 != $password2) {
header('Location: register.php');
}
if(strlen($username > 30) {
header('Location: register.php');
}
[/lua]
By the way, I would add in an error message. But that's how you do it.
Posts: 1,725
Threads: 105
Joined: Feb 2011
Reputation:
0
But, password2 is in a database?
Posts: 1,012
Threads: 94
Joined: May 2011
Reputation:
0
08-13-2011, 05:07 PM
(This post was last modified: 08-13-2011, 05:07 PM by manbat116.)
You can put it in there if you want. But I just check it right when they load the page. Just store there hashed password in the database.
Posts: 1,725
Threads: 105
Joined: Feb 2011
Reputation:
0
I do not understand.
Code?
Posts: 1,012
Threads: 94
Joined: May 2011
Reputation:
0
Okay, I put the passowrd1 in the database (hashed of course) BUT
When they fill out a form:
[lua]
<html>
<!--Form to register-->
<form name="register action="register.php" method="post">
Username: <input type="text" name="username" maxlength="30" />
Password: <input type="password" name="password1" />
Password Again: <input type="password" name="password2" />
<input type ="submit" value="Register" />
</form>
</html>
[/lua]
As you can see I have 'Password' (password1) and 'Password Again' (password2) then, when they hit register, it sends username and password, and ID in the database. NOT password2. Password2 is checked when they register ONLY. Why would you need it it in the database. Just check it when they load the page.
Posts: 823
Threads: 75
Joined: Apr 2011
Reputation:
0
08-13-2011, 05:34 PM
(This post was last modified: 08-13-2011, 05:37 PM by Voided.)
He's asking how to get a password from a SQL database.
Assuming you have a SQL database connection, use this query:
[lua]
$result = mysql_query("SELECT * FROM users WHERE username = '".mysql_real_escape_string($_POST['username'])."' AND password = '".hash('sha256',$_POST['password'])."'");
if (mysql_num_rows($result)) {
// success
} else {
// fail
}
[/lua]
Remember to hash your password. In the example I used sha256.