The following warnings occurred:
Warning [2] Undefined array key "lockoutexpiry" - Line: 94 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 94 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "lockoutexpiry" - Line: 573 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 573 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $can_access_moderationqueue - Line: 752 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 752 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 892 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 892 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $awaitingusers - Line: 34 - File: global.php(959) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/global.php(959) : eval()'d code 34 errorHandler->error
/global.php 959 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 1024 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 1024 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5327 - File: inc/functions.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions.php 5327 errorHandler->error
/global.php 1024 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(257) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/printthread.php(257) : eval()'d code 2 errorHandler->error
/printthread.php 257 eval
/printthread.php 117 printthread_multipage
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



2DWorlds Forums
PHP/SQL - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: Off Topic (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=5)
+--- Forum: Programming (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=30)
+--- Thread: PHP/SQL (/showthread.php?tid=7980)

Pages: 1 2


PHP/SQL - Dignity - 08-12-2011

I have two questions about PHP+SQL.
  • How do I check if something exists in a table? - Done
  • How to I check if something equals something?

By "equals something" I mean something like

Code:
if Pass='$psw'
setcookie("User", "");

Only in SQL.


RE: PHP/SQL - Chaos - 08-12-2011

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.



RE: PHP/SQL - Dignity - 08-13-2011

Let me re-state my question.

I have a login system, and for login, how do I check if the input equals the data?


RE: PHP/SQL - Chaos - 08-13-2011

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.




RE: PHP/SQL - Dignity - 08-13-2011

But, password2 is in a database?


RE: PHP/SQL - Chaos - 08-13-2011

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.


RE: PHP/SQL - Dignity - 08-13-2011

I do not understand.

Code?


RE: PHP/SQL - Chaos - 08-13-2011

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.



RE: PHP/SQL - noob007 - 08-13-2011

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.


RE: PHP/SQL - Dignity - 08-13-2011

I'ts not working

http://virtualscope.x10.mx/Account/cookie.php

Source:
Code:
<?php
include("../api.php");
@ $con=mysql_connect("*", "*", "*");
if (!$con)
{
sError(mysql_error());
}

$result = mysql_query("SELECT * FROM User WHERE Username = '".mysql_real_escape_string($_POST['user'])."' AND Password = '".hash('sha256',$_POST['psw'])."'");

if (mysql_num_rows($result)) {
setcookie("user", $_REQUEST['user']);
} else {
sError("Incorrect username/password");
}
?>