Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,625,394 members, 6,123,007 topics. Date: Thursday, 28 January 2021 at 09:48 AM

Codedreamer's Posts

Nairaland Forum / Codedreamer's Profile / Codedreamer's Posts

(1) (of 1 pages)

Programming / Re: The Hardest Topic You Encountered While Learning Any Programming Language? by Codedreamer: 11:00pm On Nov 27, 2020
am currently struggling to learn PHP...
please if there's a group or persons that could assist me or advice me on this programme, I will greatly appreciated
Use this link https://www.tutorialrepublic.com/php-tutorial/ Try to build a login/logout system.
Travel / Any International Scholarship Beneficiary On Here? by Codedreamer: 7:59pm On Nov 25, 2020
Hello nairalanders.

Is there anyone on here who is a beneficiary of an international scholarship for post graduate studies OR do you know anyone who is a beneficiary.

Please we would like to hear your story. Tell us how you got your scholarship so that aspirants can learn. Thanks.
Programming / Re: PHP Help - How Can I Allow Only Admin To Access A Page? by Codedreamer: 6:57pm On Nov 22, 2020

This should do it. It seems you are not working with routes, middlewares and the likes.

It's better you check for the opposite though.
Something like...

If (! $admin){
//redirect to other page

Then you continue with the dashboard.php codes. The check should be the first thing in the dashboard.php file.

A friendly advice.

If you need to combine html and Php codes for any reason, especially for a project, consider using php templates. They are specifically made for this reason.
Thanks very much for the help.
Programming / Re: PHP Help - How Can I Allow Only Admin To Access A Page? by Codedreamer: 6:30pm On Nov 22, 2020

Another way to go about it is to create a user_type column in the users table. user_type will be an enum data type with options like (user, admin, moderator, site_owner...).

So you'll check, if $user->user_type === "admin".

Preferably, the check should be in a middleware.

Thanks for your reply. That means all my dashboard.php HTML codes will have to be inside a condition and they will all be echoed. Currently, they are written in plain HTML. I'm still learning!

If (condition) {
echo " all HTML codes ";
else {
echo " Only admin can access this page";
Programming / Re: PHP Help - How Can I Allow Only Admin To Access A Page? by Codedreamer: 6:26pm On Nov 22, 2020

Am guessing you are storing the user id or user name of logged in user in a session variable. So, go to your users table in db and create a column is_admin with default value of 0. 0 indicates not admin while 1 indicates admin.
So in the page you want to restrict, grab the user I'd from session, run a query to check if is_admin, proceed if so or redirect if necessary.
Thanks for your reply. From your write-up, it seems i will have to write all my dashboard.php contents inside a condition. Currently, all my dashboard.php HTML codes are written in plain HTML (can i write plain html inside a php condition) or Do I have to echo them all.

For example: if ($_SESSION['username'] == $admin) {
echo "all dashboard HTML code";
else {
redirect to another page
Programming / Re: Pls Tech Gurus..i Dont Understand What Apis Mean In Javascript.. Help! by Codedreamer: 6:01pm On Nov 22, 2020
API means Application Programming Interface. It allows you to interact with another software from your own software. For example, if you integrate google map API in your website, you will be able to display google map in your site.

Another example - if you want to create a website that displays lists of all foods on earth, you do not need to type all the foods in your code. All you have to do is to integrate with an API software that has all lists of foods and loop through them in your code.


Programming / PHP Help - How Can I Allow Only Admin To Access A Page? by Codedreamer: 4:47pm On Nov 22, 2020
Hello coders!

I am currently developing a Student Management System using PHP and MySql where an admin (principal) can log in to the dashboard to manage accounts of students and staffs, update results, add new student, etc. Students can also log in to view their profile and results.

I have been able to create the dashboard and student login system using session , but the problem is If a user goes to 'dashboard.php', they will be able to view all the dashboard settings, I want only the admin to be able to view this page.

Please how can I achieve this.
Celebrities / Re: Omah Lay: 'This Time Last Year, I Didn't Know People Would Ever Hear My Songs' by Codedreamer: 10:30pm On Nov 20, 2020
That's life for you.. By this time last 5 years i never knew I'd be a web developer.. But today i build websites for a living
How do you market your service sir?
Religion / Re: Laurie Idahosa: Breast Cancer Killed My Grandmothers by Codedreamer: 1:38pm On Oct 31, 2020
Thank God for her life. Prayer works!

Contact me for your website design!

1 Like

Programming / Re: Experienced Wordpress Designer Needed In Port Harcourt by Codedreamer: 4:08pm On Sep 25, 2020
I am available for remote works. Thanks.

(1) (of 1 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2021 Oluwaseun Osewa. All rights reserved. See How To Advertise. 39
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.