Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17249 > unrolled thread

Problem validating user and hashed value in db

Started bywart2ww <fcc@bmi.net>
First post2017-01-10 12:46 -0800
Last post2017-01-11 09:22 -0500
Articles 20 on this page of 42 — 5 participants

Back to article view | Back to comp.lang.php


Contents

  Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-10 12:46 -0800
    Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-10 22:39 -0500
      Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-10 19:51 -0800
        Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-10 23:28 -0500
          Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-10 22:32 -0800
            Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-11 12:47 +0100
              Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-11 09:07 -0500
                Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-11 15:37 +0100
                  Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-11 15:40 -0500
                  Re: Problem validating user and hashed value in db Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-11 23:18 +0100
                    Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 07:32 -0800
                      Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-12 17:23 +0100
                        Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 10:18 -0800
                          Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-12 19:36 +0100
                            Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 11:12 -0800
                              Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 12:05 -0800
                                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-12 15:20 -0500
                                  Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 13:51 -0800
                                    Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-12 17:00 -0500
                                  Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-12 13:53 -0800
                                    Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-12 17:02 -0500
                                      Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 07:16 -0800
                                        Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 10:39 -0500
                                          Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 09:06 -0800
                                            Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 12:58 -0500
                                              Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 10:30 -0800
                                                Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 13:57 -0500
                                                  Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 13:29 -0800
                                                    Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 16:57 -0500
                                                      Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 14:23 -0800
                                                        Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-14 13:03 -0500
                                                Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-13 20:02 +0100
                                                  Re: Problem validating user and hashed value in db Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-13 21:35 +0100
                                                    Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-13 16:24 -0500
                                                      Re: Problem validating user and hashed value in db Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-14 02:37 +0000
                                                        Re: Problem validating user and hashed value in db wart2ww <fcc@bmi.net> - 2017-01-13 19:20 -0800
                                                        Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-14 12:57 -0500
                                                        Re: Problem validating user and hashed value in db Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-14 19:47 +0100
                                                          Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-14 14:00 -0500
                            Re: Problem validating user and hashed value in db Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-13 16:27 +0100
                              Re: Problem validating user and hashed value in db "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-01-13 16:39 +0100
            Re: Problem validating user and hashed value in db Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-11 09:22 -0500

Page 1 of 3  [1] 2 3  Next page →


#17249 — Problem validating user and hashed value in db

Fromwart2ww <fcc@bmi.net>
Date2017-01-10 12:46 -0800
SubjectProblem validating user and hashed value in db
Message-ID<59dee77f-3973-468a-bc21-2cbfd2fe4d7a@googlegroups.com>
I have a form that only asks for a password. The valid password is encriypted using password_hash($userPW, PASSWORD_BCRYPT, [12]) and stored in the database.

The connection is valid and I get a confirmation that the connection has been made. However, when it comes to validating the userpw and the hashed value I get an error message. Below is the code and where the error is occuring. Being new, I am asking for help after 6 hours of working on this.

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>

<body>

<?php
// userpw entered by user for validation is 123abc
// $hashedPW is stored in the db
// $hashedPW = '$2y$10$fLAVp7OMvvKzXYKHPGJ7kucfj7HxJilnrsHXo/b1FLL44d.EoSe7e';

// test to see if submit button has been clicked
if(isset($_POST['submit'])) {
	$userPW = trim($_POST['pass']);
		
	$userQuery = $con->prepare("SELECT userpw FROM myPasswordDb");

	$userQuery->execute([
		'userPW'=> $userPW
	]);
	
	$pw = $userQuery->fetch(PDO::FETCH_OBJ);

	$db_password = $pw->userPW; // error seems to be here - returns false
	
	if(password_verify($userPW, $db_password)){
		echo "<p class='bg-danger'>user verified</p>";
	} else {
		echo "<p class='bg-danger'>user not verified</p>";
	}
}

?>


<form action="" method="post" autocomplete="off">

	<label for="pass" style="margin-top: 30px; margin-left: 30px;">
		Password
		<input type="text" name="pass" style="margin-left: 10px;">
	</label><br><br>

	<input type="submit" name="submit">
</form>

</body>
</html>












[toc] | [next] | [standalone]


#17250

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-10 22:39 -0500
Message-ID<o54991$5ak$1@jstuckle.eternal-september.org>
In reply to#17249
On 1/10/2017 3:46 PM, wart2ww wrote:
> I have a form that only asks for a password. The valid password is encriypted using password_hash($userPW, PASSWORD_BCRYPT, [12]) and stored in the database.
> 
> The connection is valid and I get a confirmation that the connection has been made. However, when it comes to validating the userpw and the hashed value I get an error message. Below is the code and where the error is occuring. Being new, I am asking for help after 6 hours of working on this.
> 
> <!doctype html>
> <html lang="en">
> <head>
> <meta charset="UTF-8">
> <title>Login</title>
> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
> </head>
> 
> <body>
> 
> <?php
> // userpw entered by user for validation is 123abc
> // $hashedPW is stored in the db
> // $hashedPW = '$2y$10$fLAVp7OMvvKzXYKHPGJ7kucfj7HxJilnrsHXo/b1FLL44d.EoSe7e';
> 
> // test to see if submit button has been clicked
> if(isset($_POST['submit'])) {
> 	$userPW = trim($_POST['pass']);
> 		
> 	$userQuery = $con->prepare("SELECT userpw FROM myPasswordDb");
> 
> 	$userQuery->execute([
> 		'userPW'=> $userPW
> 	]);
> 	
> 	$pw = $userQuery->fetch(PDO::FETCH_OBJ);
> 
> 	$db_password = $pw->userPW; // error seems to be here - returns false
> 	
> 	if(password_verify($userPW, $db_password)){
> 		echo "<p class='bg-danger'>user verified</p>";
> 	} else {
> 		echo "<p class='bg-danger'>user not verified</p>";
> 	}
> }
> 
> ?>
> 
> 
> <form action="" method="post" autocomplete="off">
> 
> 	<label for="pass" style="margin-top: 30px; margin-left: 30px;">
> 		Password
> 		<input type="text" name="pass" style="margin-left: 10px;">
> 	</label><br><br>
> 
> 	<input type="submit" name="submit">
> </form>
> 
> </body>
> </html>
> 
> 

You didn't provide the MySQL table definition, so this is somewhat a
guess.  But what's in $pw where you get the error?  Try

print_r($pw);

That should help.

Also, be aware you aren't using any selection criteria, so every row in
the table will be retrieved.  And since you didn't use ORDER BY, the
order of retrieval is not guaranteed.  If you ever have more than one
row in the table, this will eventually cause you problems.

You didn't post the code for your password_verify function, so it's
unknown if you'll have a problem there or not.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17251

Fromwart2ww <fcc@bmi.net>
Date2017-01-10 19:51 -0800
Message-ID<ae93ff1c-ec6a-479e-a77c-82cac5bc550f@googlegroups.com>
In reply to#17250
On Tuesday, January 10, 2017 at 7:38:51 PM UTC-8, Jerry Stuckle wrote:
> On 1/10/2017 3:46 PM, wart2ww wrote:
> > I have a form that only asks for a password. The valid password is encriypted using password_hash($userPW, PASSWORD_BCRYPT, [12]) and stored in the database.
> > 
> > The connection is valid and I get a confirmation that the connection has been made. However, when it comes to validating the userpw and the hashed value I get an error message. Below is the code and where the error is occuring. Being new, I am asking for help after 6 hours of working on this.
> > 
> > <!doctype html>
> > <html lang="en">
> > <head>
> > <meta charset="UTF-8">
> > <title>Login</title>
> > <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
> > </head>
> > 
> > <body>
> > 
> > <?php
> > // userpw entered by user for validation is 123abc
> > // $hashedPW is stored in the db
> > // $hashedPW = '$2y$10$fLAVp7OMvvKzXYKHPGJ7kucfj7HxJilnrsHXo/b1FLL44d.EoSe7e';
> > 
> > // test to see if submit button has been clicked
> > if(isset($_POST['submit'])) {
> > 	$userPW = trim($_POST['pass']);
> > 		
> > 	$userQuery = $con->prepare("SELECT userpw FROM myPasswordDb");
> > 
> > 	$userQuery->execute([
> > 		'userPW'=> $userPW
> > 	]);
> > 	
> > 	$pw = $userQuery->fetch(PDO::FETCH_OBJ);
> > 
> > 	$db_password = $pw->userPW; // error seems to be here - returns false
> > 	
> > 	if(password_verify($userPW, $db_password)){
> > 		echo "<p class='bg-danger'>user verified</p>";
> > 	} else {
> > 		echo "<p class='bg-danger'>user not verified</p>";
> > 	}
> > }
> > 
> > ?>
> > 
> > 
> > <form action="" method="post" autocomplete="off">
> > 
> > 	<label for="pass" style="margin-top: 30px; margin-left: 30px;">
> > 		Password
> > 		<input type="text" name="pass" style="margin-left: 10px;">
> > 	</label><br><br>
> > 
> > 	<input type="submit" name="submit">
> > </form>
> > 
> > </body>
> > </html>
> > 
> > 
> 
> You didn't provide the MySQL table definition, so this is somewhat a
> guess.  But what's in $pw where you get the error?  Try
> 
> print_r($pw);
> 
> That should help.
> 
> Also, be aware you aren't using any selection criteria, so every row in
> the table will be retrieved.  And since you didn't use ORDER BY, the
> order of retrieval is not guaranteed.  If you ever have more than one
> row in the table, this will eventually cause you problems.
> 
> You didn't post the code for your password_verify function, so it's
> unknown if you'll have a problem there or not.
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstucklex@attglobal.net
> ==================

The table is only designed to have one field and one record so I didn't see the need for a WHERE clause.

I think the verify is included: password_verify($userPW, $db_password) I have done a print_r and $pw does return the value in the table. The problem is that the next statement($db_password = $pw->userPW; // error seems to be here - returns false) is where everything stops. Nothing happens after the FETCH statement. I hope that clears it up for you. If not, let me know. Thanks.

[toc] | [prev] | [next] | [standalone]


#17252

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-10 23:28 -0500
Message-ID<o54c5n$b4s$1@jstuckle.eternal-september.org>
In reply to#17251
On 1/10/2017 10:51 PM, wart2ww wrote:
> On Tuesday, January 10, 2017 at 7:38:51 PM UTC-8, Jerry Stuckle wrote:
>> On 1/10/2017 3:46 PM, wart2ww wrote:
>>> I have a form that only asks for a password. The valid password is encriypted using password_hash($userPW, PASSWORD_BCRYPT, [12]) and stored in the database.
>>>
>>> The connection is valid and I get a confirmation that the connection has been made. However, when it comes to validating the userpw and the hashed value I get an error message. Below is the code and where the error is occuring. Being new, I am asking for help after 6 hours of working on this.
>>>
>>> <!doctype html>
>>> <html lang="en">
>>> <head>
>>> <meta charset="UTF-8">
>>> <title>Login</title>
>>> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
>>> </head>
>>>
>>> <body>
>>>
>>> <?php
>>> // userpw entered by user for validation is 123abc
>>> // $hashedPW is stored in the db
>>> // $hashedPW = '$2y$10$fLAVp7OMvvKzXYKHPGJ7kucfj7HxJilnrsHXo/b1FLL44d.EoSe7e';
>>>
>>> // test to see if submit button has been clicked
>>> if(isset($_POST['submit'])) {
>>> 	$userPW = trim($_POST['pass']);
>>> 		
>>> 	$userQuery = $con->prepare("SELECT userpw FROM myPasswordDb");
>>>
>>> 	$userQuery->execute([
>>> 		'userPW'=> $userPW
>>> 	]);
>>> 	
>>> 	$pw = $userQuery->fetch(PDO::FETCH_OBJ);
>>>
>>> 	$db_password = $pw->userPW; // error seems to be here - returns false
>>> 	
>>> 	if(password_verify($userPW, $db_password)){
>>> 		echo "<p class='bg-danger'>user verified</p>";
>>> 	} else {
>>> 		echo "<p class='bg-danger'>user not verified</p>";
>>> 	}
>>> }
>>>
>>> ?>
>>>
>>>
>>> <form action="" method="post" autocomplete="off">
>>>
>>> 	<label for="pass" style="margin-top: 30px; margin-left: 30px;">
>>> 		Password
>>> 		<input type="text" name="pass" style="margin-left: 10px;">
>>> 	</label><br><br>
>>>
>>> 	<input type="submit" name="submit">
>>> </form>
>>>
>>> </body>
>>> </html>
>>>
>>>
>>
>> You didn't provide the MySQL table definition, so this is somewhat a
>> guess.  But what's in $pw where you get the error?  Try
>>
>> print_r($pw);
>>
>> That should help.
>>
>> Also, be aware you aren't using any selection criteria, so every row in
>> the table will be retrieved.  And since you didn't use ORDER BY, the
>> order of retrieval is not guaranteed.  If you ever have more than one
>> row in the table, this will eventually cause you problems.
>>
>> You didn't post the code for your password_verify function, so it's
>> unknown if you'll have a problem there or not.
>>
>> -- 
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> jstucklex@attglobal.net
>> ==================
> 
> The table is only designed to have one field and one record so I didn't see the need for a WHERE clause.
> 
> I think the verify is included: password_verify($userPW, $db_password) I have done a print_r and $pw does return the value in the table. The problem is that the next statement($db_password = $pw->userPW; // error seems to be here - returns false) is where everything stops. Nothing happens after the FETCH statement. I hope that clears it up for you. If not, let me know. Thanks.
> 

So, what does print_r($pw) actually show?  That is critical to the rest
of the code.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17253

Fromwart2ww <fcc@bmi.net>
Date2017-01-10 22:32 -0800
Message-ID<04c4b8b6-9fba-4306-b241-72458fbbd917@googlegroups.com>
In reply to#17252
On Tuesday, January 10, 2017 at 8:28:10 PM UTC-8, Jerry Stuckle wrote:
> On 1/10/2017 10:51 PM, wart2ww wrote:
> > On Tuesday, January 10, 2017 at 7:38:51 PM UTC-8, Jerry Stuckle wrote:
> >> On 1/10/2017 3:46 PM, wart2ww wrote:
> >>> I have a form that only asks for a password. The valid password is encriypted using password_hash($userPW, PASSWORD_BCRYPT, [12]) and stored in the database.
> >>>
> >>> The connection is valid and I get a confirmation that the connection has been made. However, when it comes to validating the userpw and the hashed value I get an error message. Below is the code and where the error is occuring. Being new, I am asking for help after 6 hours of working on this.
> >>>
> >>> <!doctype html>
> >>> <html lang="en">
> >>> <head>
> >>> <meta charset="UTF-8">
> >>> <title>Login</title>
> >>> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
> >>> </head>
> >>>
> >>> <body>
> >>>
> >>> <?php
> >>> // userpw entered by user for validation is 123abc
> >>> // $hashedPW is stored in the db
> >>> // $hashedPW = '$2y$10$fLAVp7OMvvKzXYKHPGJ7kucfj7HxJilnrsHXo/b1FLL44d.EoSe7e';
> >>>
> >>> // test to see if submit button has been clicked
> >>> if(isset($_POST['submit'])) {
> >>> 	$userPW = trim($_POST['pass']);
> >>> 		
> >>> 	$userQuery = $con->prepare("SELECT userpw FROM myPasswordDb");
> >>>
> >>> 	$userQuery->execute([
> >>> 		'userPW'=> $userPW
> >>> 	]);
> >>> 	
> >>> 	$pw = $userQuery->fetch(PDO::FETCH_OBJ);
> >>>
> >>> 	$db_password = $pw->userPW; // error seems to be here - returns false
> >>> 	
> >>> 	if(password_verify($userPW, $db_password)){
> >>> 		echo "<p class='bg-danger'>user verified</p>";
> >>> 	} else {
> >>> 		echo "<p class='bg-danger'>user not verified</p>";
> >>> 	}
> >>> }
> >>>
> >>> ?>
> >>>
> >>>
> >>> <form action="" method="post" autocomplete="off">
> >>>
> >>> 	<label for="pass" style="margin-top: 30px; margin-left: 30px;">
> >>> 		Password
> >>> 		<input type="text" name="pass" style="margin-left: 10px;">
> >>> 	</label><br><br>
> >>>
> >>> 	<input type="submit" name="submit">
> >>> </form>
> >>>
> >>> </body>
> >>> </html>
> >>>
> >>>
> >>
> >> You didn't provide the MySQL table definition, so this is somewhat a
> >> guess.  But what's in $pw where you get the error?  Try
> >>
> >> print_r($pw);
> >>
> >> That should help.
> >>
> >> Also, be aware you aren't using any selection criteria, so every row in
> >> the table will be retrieved.  And since you didn't use ORDER BY, the
> >> order of retrieval is not guaranteed.  If you ever have more than one
> >> row in the table, this will eventually cause you problems.
> >>
> >> You didn't post the code for your password_verify function, so it's
> >> unknown if you'll have a problem there or not.
> >>
> >> -- 
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> jstucklex@attglobal.net
> >> ==================
> > 
> > The table is only designed to have one field and one record so I didn't see the need for a WHERE clause.
> > 
> > I think the verify is included: password_verify($userPW, $db_password) I have done a print_r and $pw does return the value in the table. The problem is that the next statement($db_password = $pw->userPW; // error seems to be here - returns false) is where everything stops. Nothing happens after the FETCH statement. I hope that clears it up for you. If not, let me know. Thanks.
> > 
> 
> So, what does print_r($pw) actually show?  That is critical to the rest
> of the code.
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstucklex@attglobal.net
> ==================

Just ran the print_r and got nothing. In my attempts, at one point I did get the db table value but I am not now. Sorry for the confusion.

[toc] | [prev] | [next] | [standalone]


#17255

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2017-01-11 12:47 +0100
Message-ID<o55614$u1$1@solani.org>
In reply to#17253
On 11.01.2017 at 07:32, wart2ww wrote:

> On Tuesday, January 10, 2017 at 8:28:10 PM UTC-8, Jerry Stuckle wrote:
>
>> So, what does print_r($pw) actually show?  That is critical to the rest
>> of the code.
> 
> Just ran the print_r and got nothing. In my attempts, at one point I did get the db table value but I am not now. Sorry for the confusion.

Don't use print_r(), but rather var_dump().

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#17256

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-11 09:07 -0500
Message-ID<o55e2c$mdh$1@jstuckle.eternal-september.org>
In reply to#17255
On 1/11/2017 6:47 AM, Christoph M. Becker wrote:
> On 11.01.2017 at 07:32, wart2ww wrote:
> 
>> On Tuesday, January 10, 2017 at 8:28:10 PM UTC-8, Jerry Stuckle wrote:
>>
>>> So, what does print_r($pw) actually show?  That is critical to the rest
>>> of the code.
>>
>> Just ran the print_r and got nothing. In my attempts, at one point I did get the db table value but I am not now. Sorry for the confusion.
> 
> Don't use print_r(), but rather var_dump().
> 

Either one works, Christoph.  They just show the information in a
slightly different way.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17258

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2017-01-11 15:37 +0100
Message-ID<o55fvp$89q$1@solani.org>
In reply to#17256
On 11.01.2017 at 15:07, Jerry Stuckle wrote:

> On 1/11/2017 6:47 AM, Christoph M. Becker wrote:
>> On 11.01.2017 at 07:32, wart2ww wrote:
>>
>>> On Tuesday, January 10, 2017 at 8:28:10 PM UTC-8, Jerry Stuckle wrote:
>>>
>>>> So, what does print_r($pw) actually show?  That is critical to the rest
>>>> of the code.
>>>
>>> Just ran the print_r and got nothing. In my attempts, at one point I did get the db table value but I am not now. Sorry for the confusion.
>>
>> Don't use print_r(), but rather var_dump().
>>
> 
> Either one works, Christoph.  They just show the information in a
> slightly different way.

print_r(false) produces no output, while var_dump(false) does.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#17259

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-11 15:40 -0500
Message-ID<o5654s$hmv$1@jstuckle.eternal-september.org>
In reply to#17258
On 1/11/2017 9:37 AM, Christoph M. Becker wrote:
> On 11.01.2017 at 15:07, Jerry Stuckle wrote:
> 
>> On 1/11/2017 6:47 AM, Christoph M. Becker wrote:
>>> On 11.01.2017 at 07:32, wart2ww wrote:
>>>
>>>> On Tuesday, January 10, 2017 at 8:28:10 PM UTC-8, Jerry Stuckle wrote:
>>>>
>>>>> So, what does print_r($pw) actually show?  That is critical to the rest
>>>>> of the code.
>>>>
>>>> Just ran the print_r and got nothing. In my attempts, at one point I did get the db table value but I am not now. Sorry for the confusion.
>>>
>>> Don't use print_r(), but rather var_dump().
>>>
>>
>> Either one works, Christoph.  They just show the information in a
>> slightly different way.
> 
> print_r(false) produces no output, while var_dump(false) does.
> 

Which in itself tells you what the value is.  I prefer print_r() with
new programmers because the output is more human-readable.  var_dump()
often confuses more than it helps.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17260

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-01-11 23:18 +0100
Message-ID<1637589.atdPhlSkOF@PointedEars.de>
In reply to#17258
Christoph M. Becker wrote:

> On 11.01.2017 at 15:07, Jerry Stuckle wrote:
>> On 1/11/2017 6:47 AM, Christoph M. Becker wrote:
>>> On 11.01.2017 at 07:32, wart2ww wrote:
>>>> On Tuesday, January 10, 2017 at 8:28:10 PM UTC-8, Jerry Stuckle wrote:
>>>>> So, what does print_r($pw) actually show?  That is critical to the
>>>>> rest of the code.
>>>> Just ran the print_r and got nothing. In my attempts, at one point I
>>>> did get the db table value but I am not now. Sorry for the confusion.
>>> Don't use print_r(), but rather var_dump().
>> Either one works, Christoph.  They just show the information in a
>> slightly different way.
> 
> print_r(false) produces no output, while var_dump(false) does.

That is also true for the string of zero length and the NULL value, because 
that is their string representation (the result of converting them to the 
string type).  PHP 101.

With Xdebug so configured and loaded, var_dump() also has the advantage over 
print_r() that it prints colored output, prepends '<pre>' and appends 
'</pre>', and limits by default the output for nested arrays.

-- 
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#17263

Fromwart2ww <fcc@bmi.net>
Date2017-01-12 07:32 -0800
Message-ID<40785270-a157-4582-a129-e5afb0f94714@googlegroups.com>
In reply to#17260
On Wednesday, January 11, 2017 at 2:18:09 PM UTC-8, Thomas 'PointedEars' Lahn wrote:
> Christoph M. Becker wrote:
> 
> > On 11.01.2017 at 15:07, Jerry Stuckle wrote:
> >> On 1/11/2017 6:47 AM, Christoph M. Becker wrote:
> >>> On 11.01.2017 at 07:32, wart2ww wrote:
> >>>> On Tuesday, January 10, 2017 at 8:28:10 PM UTC-8, Jerry Stuckle wrote:
> >>>>> So, what does print_r($pw) actually show?  That is critical to the
> >>>>> rest of the code.
> >>>> Just ran the print_r and got nothing. In my attempts, at one point I
> >>>> did get the db table value but I am not now. Sorry for the confusion.
> >>> Don't use print_r(), but rather var_dump().
> >> Either one works, Christoph.  They just show the information in a
> >> slightly different way.
> > 
> > print_r(false) produces no output, while var_dump(false) does.
> 
> That is also true for the string of zero length and the NULL value, because 
> that is their string representation (the result of converting them to the 
> string type).  PHP 101.
> 
> With Xdebug so configured and loaded, var_dump() also has the advantage over 
> print_r() that it prints colored output, prepends '<pre>' and appends 
> '</pre>', and limits by default the output for nested arrays.
> 
> -- 
> PointedEars
> Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Well, I have been doing testing some of the posts suggestions and confirm that print_r() and var_dump show the hashed password in the database. I have also echoed out $userPW and $db_password in a line just before the verify_password function. The results display and are correct. This code works correctly on my wamp local host just fine. When I copy it to the websites server, it works up to the echo statement but then nothing happened so I thought 'rehash the userPW, copy it to the db and try again. Still not running the verify function. Any other ideas? Maybe a setting on the server? Any other suggestions on how to code this for it to work? Thanks

[toc] | [prev] | [next] | [standalone]


#17264

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2017-01-12 17:23 +0100
Message-ID<o58ahb$5t4$1@solani.org>
In reply to#17263
On 12.01.2017 at 16:32, wart2ww wrote:

> Well, I have been doing testing some of the posts suggestions and
> confirm that print_r() and var_dump show the hashed password in the
> database. I have also echoed out $userPW and $db_password in a line
> just before the verify_password function. The results display and are
> correct. This code works correctly on my wamp local host just fine.
> When I copy it to the websites server, it works up to the echo
> statement but then nothing happened so I thought 'rehash the userPW,
> copy it to the db and try again. Still not running the verify
> function. Any other ideas?

Check the error logs on the server, and the return values of the
relevant function calls.  For instance, what does

  $userQuery->execute([
    'userPW'=> $userPW
  ]);

return?  And why do you pass an input parameter to a query that has no
placeholder?

-- 
Christoph M. Becker


[toc] | [prev] | [next] | [standalone]


#17265

Fromwart2ww <fcc@bmi.net>
Date2017-01-12 10:18 -0800
Message-ID<46bf833a-2b4c-4258-a9bf-b7f7d0ab224a@googlegroups.com>
In reply to#17264
On Thursday, January 12, 2017 at 8:23:11 AM UTC-8, Christoph M. Becker wrote:
> On 12.01.2017 at 16:32, wart2ww wrote:
> 
> > Well, I have been doing testing some of the posts suggestions and
> > confirm that print_r() and var_dump show the hashed password in the
> > database. I have also echoed out $userPW and $db_password in a line
> > just before the verify_password function. The results display and are
> > correct. This code works correctly on my wamp local host just fine.
> > When I copy it to the websites server, it works up to the echo
> > statement but then nothing happened so I thought 'rehash the userPW,
> > copy it to the db and try again. Still not running the verify
> > function. Any other ideas?
> 
> Check the error logs on the server, and the return values of the
> relevant function calls.  For instance, what does
> 
>   $userQuery->execute([
>     'userPW'=> $userPW
>   ]);
> 
> return?  And why do you pass an input parameter to a query that has no
> placeholder?
> 
> -- 
> Christoph M. Becker

Thank you for the heads up on the error log. I did check it and got the following error message: PHP Warning:  Cannot modify header information - headers already sent by (output started at......

The sites main menu contains an option to open the same page as the php codes header('location'....

Can that be the problem?

[toc] | [prev] | [next] | [standalone]


#17266

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2017-01-12 19:36 +0100
Message-ID<o58ib6$bu4$1@solani.org>
In reply to#17265
On 12.01.2017 at 19:18, wart2ww wrote:

> On Thursday, January 12, 2017 at 8:23:11 AM UTC-8, Christoph M. Becker wrote:
>
>> Check the error logs on the server, and the return values of the
>> relevant function calls.  For instance, what does
>>
>>   $userQuery->execute([
>>     'userPW'=> $userPW
>>   ]);
>>
>> return?  And why do you pass an input parameter to a query that has no
>> placeholder?
> 
> Thank you for the heads up on the error log. I did check it and got the following error message: PHP Warning:  Cannot modify header information - headers already sent by (output started at......
> 
> The sites main menu contains an option to open the same page as the php codes header('location'....
> 
> Can that be the problem?

If an header is supposed to be sent, but isn't, that certainly could
cause all kinds of issues.  Instead of wondering whether this very issue
is caused by the failing header call, I suggest you fix it, and then
check whether the other issue still persists. :-)

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#17267

Fromwart2ww <fcc@bmi.net>
Date2017-01-12 11:12 -0800
Message-ID<10375782-d8e1-4c57-bdee-06540f32d866@googlegroups.com>
In reply to#17266
Well, that was not it. I modified the main menu's option to open the file directly and still have the same problem. What I then did was remove the header call and echoed out a message and it works great. So, finally narrowed it down to the header call. Is there another way to open an html document on the host site?

[toc] | [prev] | [next] | [standalone]


#17268

Fromwart2ww <fcc@bmi.net>
Date2017-01-12 12:05 -0800
Message-ID<9f5cff7f-01f5-4625-ba02-c8f28c001684@googlegroups.com>
In reply to#17267
On Thursday, January 12, 2017 at 11:12:15 AM UTC-8, wart2ww wrote:
> Well, that was not it. I modified the main menu's option to open the file directly and still have the same problem. What I then did was remove the header call and echoed out a message and it works great. So, finally narrowed it down to the header call. Is there another way to open an html document on the host site?

For clarification, I am not outputting any html to the page before the header.

[toc] | [prev] | [next] | [standalone]


#17269

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-12 15:20 -0500
Message-ID<o58ob1$b18$1@jstuckle.eternal-september.org>
In reply to#17268
On 1/12/2017 3:05 PM, wart2ww wrote:
> On Thursday, January 12, 2017 at 11:12:15 AM UTC-8, wart2ww wrote:
>> Well, that was not it. I modified the main menu's option to open the file directly and still have the same problem. What I then did was remove the header call and echoed out a message and it works great. So, finally narrowed it down to the header call. Is there another way to open an html document on the host site?
> 
> For clarification, I am not outputting any html to the page before the header.
> 

You don't have to be outputting any HTML before the header - ANYTHING,
including a simple space, output before the header call will cause this
message.  It includes the output from print_r() or var_dump(), and that
is expected when you're debugging.

Look for other errors in the log.  There probably is at least one before
this one.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17270

Fromwart2ww <fcc@bmi.net>
Date2017-01-12 13:51 -0800
Message-ID<64c39347-e021-4ad9-a1a2-292e828a2796@googlegroups.com>
In reply to#17269
On Thursday, January 12, 2017 at 12:20:22 PM UTC-8, Jerry Stuckle wrote:
> On 1/12/2017 3:05 PM, wart2ww wrote:
> > On Thursday, January 12, 2017 at 11:12:15 AM UTC-8, wart2ww wrote:
> >> Well, that was not it. I modified the main menu's option to open the file directly and still have the same problem. What I then did was remove the header call and echoed out a message and it works great. So, finally narrowed it down to the header call. Is there another way to open an html document on the host site?
> > 
> > For clarification, I am not outputting any html to the page before the header.
> > 
> 
> You don't have to be outputting any HTML before the header - ANYTHING,
> including a simple space, output before the header call will cause this
> message.  It includes the output from print_r() or var_dump(), and that
> is expected when you're debugging.
> 
> Look for other errors in the log.  There probably is at least one before
> this one.
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstucklex@attglobal.net
> ==================

So I guess the problem is that there is a form on the same page containing the php code. I would use an include statement but I believe that would cause the same problem.

[toc] | [prev] | [next] | [standalone]


#17272

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-12 17:00 -0500
Message-ID<o58u6o$23u$1@jstuckle.eternal-september.org>
In reply to#17270
On 1/12/2017 4:51 PM, wart2ww wrote:
> On Thursday, January 12, 2017 at 12:20:22 PM UTC-8, Jerry Stuckle wrote:
>> On 1/12/2017 3:05 PM, wart2ww wrote:
>>> On Thursday, January 12, 2017 at 11:12:15 AM UTC-8, wart2ww wrote:
>>>> Well, that was not it. I modified the main menu's option to open the file directly and still have the same problem. What I then did was remove the header call and echoed out a message and it works great. So, finally narrowed it down to the header call. Is there another way to open an html document on the host site?
>>>
>>> For clarification, I am not outputting any html to the page before the header.
>>>
>>
>> You don't have to be outputting any HTML before the header - ANYTHING,
>> including a simple space, output before the header call will cause this
>> message.  It includes the output from print_r() or var_dump(), and that
>> is expected when you're debugging.
>>
>> Look for other errors in the log.  There probably is at least one before
>> this one.
>>
> 
> So I guess the problem is that there is a form on the same page containing the php code. I would use an include statement but I believe that would cause the same problem.
> 

No, having a form on the same page as the PHP code is not a problem.
You just have to ensure the header call is made *before* any output.

In fact, it is quite common to have PHP code to process the form in the
same page as the form itself.  That way, if there is an error, you can
redisplay the form with the entered values an error message.  If there
is no error, you can process the form and use the header call to go to
the next page.

include (or, better yet, require or require_once) just allows you to put
some common code in a separate file and include it in the existing file.
 It is basically the same as doing a copy/paste of the included file
using your editor.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17271

Fromwart2ww <fcc@bmi.net>
Date2017-01-12 13:53 -0800
Message-ID<b61144dd-ec9d-457e-8cc4-33e021372547@googlegroups.com>
In reply to#17269
On Thursday, January 12, 2017 at 12:20:22 PM UTC-8, Jerry Stuckle wrote:
> On 1/12/2017 3:05 PM, wart2ww wrote:
> > On Thursday, January 12, 2017 at 11:12:15 AM UTC-8, wart2ww wrote:
> >> Well, that was not it. I modified the main menu's option to open the file directly and still have the same problem. What I then did was remove the header call and echoed out a message and it works great. So, finally narrowed it down to the header call. Is there another way to open an html document on the host site?
> > 
> > For clarification, I am not outputting any html to the page before the header.
> > 
> 
> You don't have to be outputting any HTML before the header - ANYTHING,
> including a simple space, output before the header call will cause this
> message.  It includes the output from print_r() or var_dump(), and that
> is expected when you're debugging.
> 
> Look for other errors in the log.  There probably is at least one before
> this one.
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstucklex@attglobal.net
> ==================

I am still learning PDO and am trying to understand the processing so I appreciate your help and patience tremendously.

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.php


csiph-web