PHP login to database problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

PHP login to database problem

problem im having is when i or anyone types in their user and pass into my site (user and pass also link to a sql database) it wont return any error it just says "you must be logged in to do this" heres my login.php i have spent the last two days trying to tackle it before asking for help <?php # login if (!defined('KODEVS') || KODEVS != 1) die(); class Page extends BasePage { function doStartup() { $this->setTitle('PAGE_LOGIN_TITLE'); $this->disableCache(); } function doRun() { $user = $this->doSanitizeName(@ $_POST['userid'], 20); $pass = $this->doHashPassword(@$_POST['passwd']); $db = $this->getADB(); $result = mysqli_num_rows($num_rows); $num_rows = $db->doQuery("SELECT strAccountID, strPasswd, strAuthority FROM TB_USER WHERE strAccountID ='$user' AND strPasswd ='$pass'"); if ($db->hasError()) { $this->doError('DB_ERROR'); return; } else if (!$db->hasRows()) { $this->doError('LOGIN_FAILED'); return; } $row = $db->doRead(); if ($row['strAuthority'] == 255) { $this->doError('LOGIN_BANNED'); return; } $_SESSION = array_merge($_SESSION, $row); $_SESSION['bLoggedIn'] = TRUE; $_SESSION['IP'] = $this->getRemoteIP(); header('Location: ./?page=account'); } } ?> not sure at this point where i wwent wrong

22nd Mar 2017, 10:50 PM
Anthony Lindenbaum
Anthony Lindenbaum - avatar
2 Answers
+ 1
did you create tables in mysql?
9th Apr 2017, 3:10 PM
Александр Чернуха
Александр Чернуха - avatar
0
yup the DB works fine with a different site see it at http://universalko.com I was trying to do a nicer written site but like I said login wouldn't login.
9th Apr 2017, 4:52 PM
Anthony Lindenbaum
Anthony Lindenbaum - avatar