Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Code suggestions

Questions related to using nuBuilder Forte.
Post Reply
iplayfast
Posts: 2
Joined: Fri Aug 16, 2019 7:44 am

Code suggestions

Unread post by iplayfast »

I've got a few ideas for your code, (little ones) but I don't see a github or some such link to offer them.
So here they are. nudatabase.php should fail gracefully if the user doesn't have a config set up correctly.
try {
$nuDB = new PDO("mysql:host=$DBHost;dbname=$DBName;charset=$DBCharset", $DBUser, $DBPassword, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES $DBCharset"));
}
catch ( PDOException $e) {
die($e->getMessage());
}

I'm not sure what's going on with your standalone session, you are checking to see if any var are set and if so, the user must be logged in? This system doesn't work if someone decided to edit the nuconfig.php after attempting to log in incorrectly. (my case). Stuck between active session but not logged in.
I'm not sure of the correct way to do this, but I'm sure this is wrong.
iplayfast
Posts: 2
Joined: Fri Aug 16, 2019 7:44 am

Re: Code suggestions

Unread post by iplayfast »

The following code removes the session if the database dies, allowing you to try again.

try {
$nuDB = new PDO("mysql:host=$DBHost;dbname=$DBName;charset=$DBCharset", $DBUser, $DBPassword, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES $DBCharset"));
}
catch ( PDOException $e) {
unset($_SESSION['nubuilder_session_data']);
die($e->getMessage());
}
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 447 times
Contact:

Re: Code suggestions

Unread post by kev1n »

Thank you
Post Reply