473,549 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code for login gone wrong.

19 New Member
I am having problem logging in, below is a login code. When I submit login info it says Incorrect Information, I have gone wrong somewhere in code and can't figure it out. I have used password_hash() function, checked my database and it works well. Surely somethings wrong with login code. I tried echoing $pass_db and on submitting info I see the password is echoed correctly but incorrect information is also displayed and I am not redirected to main.php as I should be.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_POST['login'])){ 
  3.     $username = $_POST['user_login'];
  4.     $password = $_POST['password_login'];
  5.  
  6.  
  7. $stmt = $db->prepare("SELECT * FROM userss WHERE username = :username");
  8. $stmt->execute(array(':username'=>$username));
  9. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  10.  
  11. $user_db = $row['username'];
  12. $pass_db = $row['password'];
  13.  
  14. if(password_verify($password, $pass_db))  {  
  15.      $_SESSION['username']=$username;
  16.     if (isset($_POST['rememberme'])) {
  17.       setcookie('username', $username,time()+31556926);
  18.      }
  19.        header("Location:main.php");
  20.  
  21. }
  22.  
  23. else {
  24.   echo "Incorrect Information!";
  25.      }
  26.  
  27. }
  28. ?>
  29.  
Oct 8 '15 #1
1 1053
RonB
589 Recognized Expert Moderator Contributor
There's no usage of the password_hash() function in the code you posted. Maybe the problem is in the code you didn't post.
Oct 8 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2329
by: lawrence | last post by:
Maybe its late and I'm tired but I don't understand what I'm seeing on the screen. I have this block of code: $choiceMade = $_GET; if ($simpleMode == "y" && $choiceMade == "") { startPage(); printEasyControlPanelOptions(); endPage();
6
1669
by: Grytpype-Thynne | last post by:
I am trying out a layout for a CSS version of the Animals in Distress site but I have a small problem, I cannot get the main text to flow under the left menu. It is probably something simple that I have either missed out or should not have put in, I just can't see it this late at night. The test page is at...
3
1675
by: Andy | last post by:
Hello, everyone, I am writing a segment of code for listing the permutation of some event sequences. I tried to use template to make the code more general. When I commented the code as shown below, the code works okay. Otherwise, it will goes to seg fault. I am puzzled on this. Can anybody give me any hints?
2
1327
by: Pixiee | last post by:
Hi, I have been trying to alter a blogger template from a 2 colum to a three. It looks just how I want it in FF but when I look in IE not only has the second sidebar slipped but also the main content. HELP. I dont know how to fix it, I thought it may be something to do with the divider tags <div> and have messed around with them but cannot...
3
1414
by: laparico2002 | last post by:
I am quite new to VB6.0. Now am trying to create a connection to NWIND.mdb. But each time i run my program i keep getting error in "Wrong argument passed" the below were what i wrote in my MODULE Public cn As ADODB.Connection Public Function dcn() Const DBpath = "C:\program files\microsoft visual studio\vb98\nwind.mdb" On Error GoTo...
2
2923
by: Zytan | last post by:
You can download them here: http://msdn2.microsoft.com/en-us/vstudio/aa718338.aspx This snippet seems wrong: Visual C# 2005 Code Snippets -filesystem -Search a Directory for Files Recursively I don't believe DirSearch will return any results for files in the root directory originally passed to it. Am I right? Here's the code:
1
1186
toxicpaint
by: toxicpaint | last post by:
I'm using visual studio 2005 with ASPX + VB and Access. Can someone help me with this, please. What I want the SQL to do is display all closed audits. The problem is that only certain people are allowed to see certain audits. So I want people to only see closed audits where they have rights. This is done by a PersonID (stored in a session). The...
1
1041
epots9
by: epots9 | last post by:
Resently our webhost upgraded from PHP4 to PHP5 and now the our online quotation system doesn't seem to be functioning correctly. It was working fine with PHP4 and now in PHP5 it doesn't, the main problem is that one of our session variables are begin overwritten, but there is no line of code that does that. Instead of getting the string i want...
2
1456
by: kangklin | last post by:
I meant for the following query (run on a friday) to return "FRIDAY" in the first column and "1" in the second column. It returns FRIDAY alright, but in the second column returns 0. Can anyone tell my why and how to fix it? SELECT a.dayofweek, (CASE WHEN a.dayofweek = 'FRIDAY' THEN 1 ELSE 0 END) daynum FROM (SELECT TO_CHAR(sysdate,'DAY') as...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7469
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.