Discussion:
Log in errors
Dale Schmitz
2018-03-11 17:05:31 UTC
Permalink
I've put out a request for reference materials, but in the interim I'd like
to know what I'm doing wrong with what should be simple error handling.



I'm learning the subject of PostgreSQL and PHP, so no doubt I'm missing
something, but just what that is I don't know. I have what's probably a
pretty simple approach to logging in from an HTML form:



$dbconn = pg_connect("dbname = <something> host=localhost port=<something>
username=$_POST[username] password=$_POST[password]");



While the HTML form that passes username and password checks for empty
strings, I'm not able to retrieve errors that address a bad username or a
password mismatch. From one of the online manual examples I've tried:



If ($dbconn == true) {

// success

} else {

echo pg_last_error($dbconn);

}



This returns nothing to the screen. I've looked at pg_result_error() but I
don't think it's what I'm looking for (am I wrong?). There are other
functions which at first glance seem like they might apply
(pg_result_status(), pg_connection_status(), etc.) but I don't think I'm
implementing them right.



How can I connect and return messages about bad usernames and mismatched
passwords?



Thanks,

Dale

Loading...