Hello, I am very new to programming and I recently decided to start with a project that allows people to sign up. I am using CGI. Although I know it is deprecated and unsafe, I am just using it to learn about it and I have no intentions of putting my “website” on the internet.
I have written code that is supposed to take in input from an HTML form and add it to the table users, which has columns email, username and password. This table has been created. I checked.
```
python
#!/usr/bin/python3
print(“Content-Type: text/html\n\n”)
import cgi
import sqlite3
import bcrypt
form = cgi.FieldStorage()
username = form.getvalue(“username”)
password = form.getvalue(“password”)
email = form.getvalue(“email”)
if username and password and email:
password = password.encode(“UTF-8”)
salt = bcrypt.gensalt()
pass_hash = bcrypt.hashpw(password, salt)
conn = sqlite3.connect(“/var/www/html/data/user.db”)
cursor = conn.cursor()
cursor.execute(“”"
INSERT INTO users(email, username, password) VALUES(?, ?, ?)
“”“, (email, username, pass_hash))
conn.commit()
conn.close()
else:
print(”“+email+”/“)
print(”“+username+”/“)
print(”“+password+”/“)
print(”Please fill out all the boxes.")
```
I’m not sure if there’s anything wrong with this code? I can’t spot anything wrong here, but for some reason when I SELECT * FROM users, sqlite3 just returns nothing… (I made the query through the app sqlite3, not using a python program btw idk if that changes things…)