stressedteen
Badges: 11
Rep:
?
#1
Report Thread starter 2 years ago
#1
how do you create different user types on sql and html??
e.g. admin and users
0
reply
winterscoming
Badges: 19
Rep:
?
#2
Report 2 years ago
#2
Are you trying to create a user for the database? or are you trying to build your own user login system with your own user table(s)?

Which Database system are you using? (e.g. MS Access, MySQL, SQL Server, Oracle, etc.)

If you're trying to create a user for the Database itself, then search the Database documentation, or a SQL tutorial for the CREATE USER statement.

Usually users don't have different types - they have 'roles' instead, which determine the permissions you have for the database (e.g. read, write, create table, etc). A database user can have many roles - i.e. a user can have both an Admin role and a User role. (creating a new role in SQL usually uses the CREATE ROLE statement, however, this varies in different database systems)
1
reply
stressedteen
Badges: 11
Rep:
?
#3
Report Thread starter 2 years ago
#3
(Original post by winterscoming)
Are you trying to create a user for the database? or are you trying to build your own user login system with your own user table(s)?

Which Database system are you using? (e.g. MS Access, MySQL, SQL Server, Oracle, etc.)

If you're trying to create a user for the Database itself, then search the Database documentation, or a SQL tutorial for the CREATE USER statement.

Usually users don't have different types - they have 'roles' instead, which determine the permissions you have for the database (e.g. read, write, create table, etc). A database user can have many roles - i.e. a user can have both an Admin role and a User role. (creating a new role in SQL usually uses the CREATE ROLE statement, however, this varies in different database systems)
Hi! Thanks so much for responding, I'm (attempting) to build my own user login system using HTML & PHP that saves data onto SQL. I created a column in my SQL 'users' table called 'user_types', and thought I'd just manually enter what type they are but that was not a good idea as it did not work hhahaha. Any suggestions?
0
reply
winterscoming
Badges: 19
Rep:
?
#4
Report 2 years ago
#4
(Original post by stressedteen)
Hi! Thanks so much for responding, I'm (attempting) to build my own user login system using HTML & PHP that saves data onto SQL. I created a column in my SQL 'users' table called 'user_types', and thought I'd just manually enter what type they are but that was not a good idea as it did not work hhahaha. Any suggestions?
You've got a lot of moving parts here so the first thing to do is to narrow it down and figure out whether the problem is your HTML, your PHP or your SQL. I'm not familiar with PHP, but there are other pieces involved too, so I can think of a couple of places to start:

Firstly, are you able to successfully run your Insert(or Update) SQL script in a stand-alone SQL client app? First thing is to make sure 100% that the SQL is OK before trying to mix it up with PHP.

Secondly, have you got any logs running on your PHP server to find out whether any errors are happening while you're doing this? For example, do you know whether it's actually able to connect to the database? (are you able to run any other queries from PHP)

I found a couple of pages with examples for switching on PHP logs, which may help narrow the problem down -
http://php.net/manual/en/function.error-log.php
https://www.w3schools.com/php/func_error_log.asp

If you're not seeing any errors from your PHP server, then you should also try attaching a debugger and putting some breakpoints down around that area so that you can actually see what's happening in real-time. http://php.net/manual/en/debugger-about.php

Lastly, I'd suggest checking the content of the data you're receiving from your HTML page. (i.e. the HTTP request body) to make sure it actually does contain the data, and that your form submit isn't just sending an HTTP POST with missing or wrong data, or maybe even using the wrong verb (e.g. POST/GET/etc.)
0
reply
stressedteen
Badges: 11
Rep:
?
#5
Report Thread starter 2 years ago
#5
(Original post by winterscoming)
You've got a lot of moving parts here so the first thing to do is to narrow it down and figure out whether the problem is your HTML, your PHP or your SQL. I'm not familiar with PHP, but there are other pieces involved too, so I can think of a couple of places to start:

Firstly, are you able to successfully run your Insert(or Update) SQL script in a stand-alone SQL client app? First thing is to make sure 100% that the SQL is OK before trying to mix it up with PHP.

Secondly, have you got any logs running on your PHP server to find out whether any errors are happening while you're doing this? For example, do you know whether it's actually able to connect to the database? (are you able to run any other queries from PHP)

I found a couple of pages with examples for switching on PHP logs, which may help narrow the problem down -
http://php.net/manual/en/function.error-log.php
https://www.w3schools.com/php/func_error_log.asp

If you're not seeing any errors from your PHP server, then you should also try attaching a debugger and putting some breakpoints down around that area so that you can actually see what's happening in real-time. http://php.net/manual/en/debugger-about.php

Lastly, I'd suggest checking the content of the data you're receiving from your HTML page. (i.e. the HTTP request body) to make sure it actually does contain the data, and that your form submit isn't just sending an HTTP POST with missing or wrong data, or maybe even using the wrong verb (e.g. POST/GET/etc.)
Thank you so much for your help!
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Regarding Ofqual's most recent update, do you think you will be given a fair grade this summer?

Yes (256)
33.82%
No (501)
66.18%

Watched Threads

View All