3 votes
Accepted

How do I check if an email adress is already used in mySQL?

Your current query will return FALSE if it failed and return data in the form of rows if succesful. You know there can only be one match in the database, if any, but the query function does not know ...
user avatar
  • 1,317
3 votes

Pset7 cs50 finance register method not displaying register.html

The post method is only used when you submit a form. Clicking register doesn't count as a post method, therefore you are skipping the entire section of your code in the post conditional, and the code ...
user avatar
3 votes
Accepted

Pset7 How do I log a user in after they register?

The problem is in: $_SESSION["id"] = $row["id"]; it should be: $_SESSION["id"] = $id;
user avatar
  • 1,369
2 votes
Accepted

Re-enrolling in CS50 for 2015

You should see both versions in your dashboard. Try signing out of edX and then sign back in. If that doesn't work, make sure that your enrolment actually went through. Go here: https://www.edx.org/...
user avatar
  • 18.3k
2 votes
Accepted

Pset7 Finance: register.php gives me an error

Do not use chmod 777 views/*. That will probably help you to get your site to load, but it is bad for security, and a terrible habit to get into. It's like taking the front door of your house off of ...
user avatar
  • 3,035
2 votes
Accepted

For register in pset 7 where I am doing wrong?

It looks like this function will always print "Both passwords don't match" and redirect to register.html (unless username or password is blank). In pseudo-C this routine would look like: if (username ...
user avatar
2 votes
Accepted

help ! I am getting an error and I dunno why ...register (pset7)

Two problems with this bit values(username:, password:". missing close paren the : goes in front of the bind variable. ( keywords in sqlite are case insensitive)
user avatar
2 votes
Accepted

Problem Set 8 / Web Track - Finance (RuntimeError: UNIQUE constraint failed)

A problem is here: if rows == 1:. Remember, execute returns a list of dictionaries, therefore that conditional is never true.
user avatar
1 vote

flask register, issue with importing cs50 module

Do you have the cs50 flask.py in /usr/lib/python2.7/site-packages/cs50/? Notice, it's importing from "this directory" from . import flask. And beware: the script is running under python 2.7 as per ...
user avatar
1 vote
Accepted

Finance check50: /register & /check return "expected status code 200, but got 400"

I suspect error message is coming from this line return render_template("/"). There is no templated named "/". In an earlier version of the code the line was return redirect("/"), which is likely what ...
user avatar
1 vote
Accepted

Finance pset, register will not insert user data

Have you looked at the flask log (in the console where you flask run). I'd expect it to be giving an error hereabouts: new_user = db.execute("INSERT INTO users ('username', 'hash') VALUES (:username, ...
user avatar
1 vote
Accepted

PSet 8, Finance, cannot submit or reset button on register

Make sure to call the form's submit method, the submit button has no such thing.
user avatar
  • 20.7k
1 vote
Accepted

Getting an error in register. Can someone help? Better explanation below

I think your INSERT fails because the id is not filled automatically if it is neither PRIMARY KEY nor AUTOINCREMENT. users.id should be PRIMARY KEY, not users.username (maybe create username with a ...
user avatar
  • 20.7k
1 vote
Accepted

Pset8 Finance Check error

Needs to be ?username=, not ?user=, in Python and JS. This test is performed without your form, just by doing that specific request. From the problem statement on /check: The route should ...
user avatar
  • 20.7k
1 vote
Accepted

pset7 finance: index not working after register

There's a problem here session["user_id"] = "id". "id" is a string literal, not users.id from the database. Remember this Hint from the spec: If str is an INSERT, and the table into which data ...
user avatar
1 vote
Accepted

The predefined login function does not seem to be working in finance

Try any user with the password password. All users are created with that same password. This hashp = generate_password_hash("password") treats password as a string literal, because of the ". You ...
user avatar
1 vote

how do I correct this error? pset7

Per the spec hints: If str is an INSERT, and the table into which data was inserted contains an autoincrementing PRIMARY KEY, then execute returns the value of the newly inserted row’s primary key. ...
user avatar
  • 18.3k
1 vote

help ! I am getting an error and I dunno why ...register (pset7)

On a quick glace maybe: On the result line: VALUES in capitals and (:username, :password")
user avatar
1 vote
Accepted

Check50 returning error pset7 register

if request.form.get("username") != True or request.form.get("password") != True or request.form.get("password") != request.form.get("confirmation"): request.form.get("username") and request.form.get("...
user avatar
  • 20.7k
1 vote

After trying to use the register function, nothing happens

Check your code: elif request.form.get("password") == request.form.get("password_confirm"): return apology("password must match password confirmation") This is wrong: whenever the passwords ...
user avatar
1 vote
Accepted

After trying to use the register function, nothing happens

Assuming your register.html is correct, and you're actually submitting the form. Executing return instantly leaves the function. Code below won't be executed. What's the rationale behind the not in ...
user avatar
  • 20.7k
1 vote
Accepted

Pset 7 - CS50 Finance: "Quote" keeps redirecting me to a register error

Check your quote.html, especially the URL the form submits to. I assume that's a Guttenbug (bug by copy&paste).
user avatar
  • 20.7k
1 vote

Pset7 Finance Register - Works fine but error in check50

Your register code gives me all greens when I run check50 with it. Have you looked at the URL that check50 gives you to see more details about the tests that are failing? It may be a problem with ...
user avatar
  • 18.3k
1 vote

Password confirmation not working

As long as password2 is "password" (literally), this will work. Are you sure you want to compare request.form.get("password2") to the string literal "password"
user avatar
1 vote
Accepted

Strange sudden error in pset7 staff implemented login (key error 'id')

That error from the supplied login means there is no column named id in the users table. It doesn't seem to have anything to do with indexes. Assuming the rest of the table is intact, you might try ...
user avatar
1 vote
Accepted

register function not returning expected apology results

What is the form action attribute in register.html? Sounds like it's calling login instead of register.
user avatar
1 vote
Accepted

confusion on session["user_id"] = rows[0]["id"] pset7

When a user is registering they do not have a user_id because they are not "in the database" until the user record is inserted. From the spec: Finally, notice how login "remembers" that a user is ...
user avatar
1 vote
Accepted

pset7 - register.php error, but new user inserted in database

Shouldn't this: $rows = CS50::query("SELECT LAST_INSERT_ID() AS id)"); be this? $rows = CS50::query("SELECT LAST_INSERT_ID() AS id");
user avatar
1 vote
Accepted

PSET7 Register not redirected to index.php

I'd add a debug line like this: dump($_SESSION); on line 40. You might be surprised to find that you are not storing the user's ID in the $_SESSION. Why not? Because even though SQL statements are ...
user avatar
  • 3,035
1 vote

I am working on pset7. register.php is working fine. But it always give back an error"id is not defined"?

Change the last line of code to $_SESSION["id"] = $id;
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible