Get up to 80 % extra points for free! More info:

Discussion – Lesson 5 - NOO-CMS - User registration in PHP

Back

 

Comments
Avatar
Inactive member:1/28/2017 11:30

Isn't this useless then... because any user can access those functions via those links...

Reply
1/28/2017 11:30
Inactive user account.
Avatar
Replies to Inactive member
David Capka Hartinger:1/28/2017 14:05

No, it isn't. Just keep reading, it's not finished.

Reply
1/28/2017 14:05
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
fezphantom
Member
Avatar
fezphantom:4/20/2017 7:49

when the user is saved in the noocms_db database, the admin column is NULL and not 0

 
Reply
4/20/2017 7:49
Avatar
IT Man
Member
Avatar
Replies to fezphantom
IT Man:4/20/2017 11:53

Maybe you have set null as the default value. Check the admin column options. :)

 
Reply
4/20/2017 11:53
Avatar
fezphantom
Member
Avatar
Replies to IT Man
fezphantom:4/21/2017 9:57

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_ad­min'],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();
        }
 
Reply
4/21/2017 9:57
Avatar
IT Man
Member
Avatar
Replies to fezphantom
IT Man:4/21/2017 10:28

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';
 
Reply
4/21/2017 10:28
Avatar
fezphantom
Member
Avatar
Replies to IT Man
fezphantom:4/21/2017 10:36

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..

 
Reply
4/21/2017 10:36
Avatar
fezphantom
Member
Avatar
Replies to IT Man
fezphantom:4/21/2017 12:04

Thanks it worked.

 
Reply
4/21/2017 12:04
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

8 messages from 8 displayed.