Log in errors

From: "Dale Schmitz" <dschmitz4(at)cox(dot)net>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Log in errors
Date: 2018-03-11 17:05:31
Message-ID: 001401d3b95b$29fc27f0$7df477d0$@cox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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

Browse pgsql-novice by date

  From Date Subject
Next Message Garry Chen 2018-03-12 15:39:50 Row Level Security Policy question
Previous Message James Keener 2018-03-11 16:51:51 Re: Error handling