Discussion – Lesson 5 - NOO-CMS - User registration in PHP
BackComments
Member
8 messages from 8 displayed.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
Comments
No, it isn't. Just keep reading, it's not finished.
when the user is saved in the noocms_db database, the admin column is NULL and not 0
Maybe you have set null
as the default value. Check the
admin
column options.
It was set to Null, but on the other hand, that means that we can't insert into the table without providing a value. I was able to tweak it by adding admin in the script the $exist script and giving it a value 0 and then used variable admin to set the $_SESSION['user_admin'],which i used to give me admin right to administration.php.
if($exists){
$message = 'Username already taken.';
}else{
Db::query('INSERT INTO user(name, password, admin)'
. ' VALUES (?,SHA1(?), ?) ',$_POST['name'],$_POST['password']. "t&#ssdf54gh", 0);
$_SESSION['user_id'] = Db::getLastId();
$_SESSION['user_name'] = $_POST['name'];
$_SESSION['user_admin'] = 'admin';
header('Location: administration.php');
exit();
}
No, you can set in phpmyadmin the default value as defined. Then you have an
input there and you can write your default value.
If you don't want to look for it, you can use this MySQL command:
ALTER TABLE `user` MODIFY COLUMN `admin` TINYINT(1) NOT NULL DEFAULT '0';
OK, i have mysql installed locally on my system together with xampp, so all script executions go to my locally installed mysql and not phpmyadmin(I tried configuring a new port for mysql xampp, but it didn't change it.). So i guess that's why i have issues with the default value..
8 messages from 8 displayed.