Just stick it in a database Category
HTML, CSS, HTTP, JS and more acronyms
C, I told you PHP was cool.
100

Assume that the table is called

clients

What SQL query would add a the user jharvard with password crimson and give him $1000 in cash?

INSERT INTO clients (username, password, cash) VALUES('jharvard','crimson', 1000)
100
What is the CSS selector that will select all paragraph tags (p) with class "lead" and id "announcements"
p.lead#announcements
100
How many bytes does a char* take on a 32-bit machine
4 bytes
200
Why do I want username to be a data type of VARCHAR(255) not CHAR(255)? (assume the longest username will be 255 characters)
VARCHAR allows you to save space when a username does not take up all 255 characters. CHAR, on the other hand, will always take 255 characters worth of space.
200
Below is a HTTP requests and responses: What is going on between the browser and thefacebook.com?
GET / HTTP/1.1
Host: thefacebook.com
Connection: keep-alive
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Pragma: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
DNT: 1
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,es;q=0.6

HTTP/1.1 301
Location: http://www.facebook.com/
Content-Type: text/html; charset=utf-8
X-FB-Debug: WuHbP8pJ8fpBFDwf2RrqaYvqBRhptxCvFNt5FlGPPaI=
Date: Tue, 19 Nov 2013 20:20:40 GMT
Connection: keep-alive
Content-Length: 0
thefacebook.com is redirecting you to facebook.com
200
True or false, C is a command-line language used at the terminal but PHP is not a command line language, PHP is only used for making websites.
False, php can be run on the command line too.
300
I am registering a new user on my website. I received their information from this form and I am now writing the PHP to add the new user to the database.
<form action="register.php" method="post">
<input name="username" placeholder="Username" type="text"/>
<input name="password" placeholder="Password" type="password"/>
<input name="confirmation" placeholder="Password (again)" type="password"/>
<button type="submit">Register</button>
</form>
$results = query("INSERT INTO users (username, hash, cash) VALUES(?, ?, 10000.0000)", _, _)
$results = query("INSERT INTO users (username, hash, cash) VALUES(?, ?, 10000.0000)",
$_POST["username"], crypt($_POST["password"])
300
What url would the user (David, a less comfortable student) see on the top of his browser after submitting this form:
<form action="http://section.cs50.net/section.php" method="get" name="section"> 
Name:
<input name="name" type="text" />
<br />
Comfort:
<input name="comfort" type="radio" value="more" /> More Comfortable
<input name="comfort" type="radio" value="less" /> Less Comfortable
<input name="comfort" type="radio" value="between" /> Somewhere in Between
<br />
<input type="submit" value="Section" />
</form>
300
Implement speller.c in PHP, load, check, size, and unload
400
This query transfers money from one account to another:
UPDATE account SET balance = balance - 1000 WHERE number = 2;
UPDATE account SET balance = balance + 1000 WHERE number = 1;
This query is not atomic. Why is this bad code to run?
Atomicity means that multiple operations happen at the same time or don’t happen at all. If the second update fails, this code would still have deducted $1000 from account 1. You fix this by defining a transaction:
START TRANSACTION;
UPDATE account SET balance = balance - 1000 WHERE number = 2;
UPDATE account SET balance = balance + 1000 WHERE number = 1;
COMMIT;
400
Given this html: write the javascript to check that the form data is valid, no blanks, and confirmation matches password:
<form action="register.php" method="post" id="registration"> 
Email: <input id="email" name="email" type="text"/>
<br/>
Password: <input id="password" name="password" type="password"/>
<br/>
Password (again): <input id="confirmation" name="confirmation" type="password"/>
<br/><br/>
<input type="submit" value="Register"/>
</form>
$('#registration').submit(function() { 
 
 if ($('#email').val() == '' || $('#password').val() == '' || $('#confirmation').val() == '') 
 return false; 
 else if ($('#password').val() != $('#confirmation').val()) 
 return false; 
 else 
 return true; 
 
 }); 
400
Implement unload for this tree, recursively:
 
typedef struct node 
{ 
 int n; 
 struct node *left; 
 struct node *right; 
} 
node;

void unload(node *ptr) 
 { 

void unload(node *ptr) 
 { 
 if (ptr == NULL) 
 return; 
 unload(ptr->left); 
 unload(ptr->right); 
 free(ptr); 
 } 
500
Let's say my PHP code to login looks like this:
$username = $_POST["username"];
$password = $_POST["password"];
query("SELECT * FROM users WHERE username='$username' AND password='$password';");
What happens which I type
' OR '1' = '1
as my password? How can you prevent this?
You will get all the rows in the database, so the user's password would authenticate.
query("SELECT * FROM users WHERE username=? AND password=?;" , $username, $password);
500
When would you want to use JavaScript rather than PHP and vice-versa.
JavaScript should be used when you want to execute code clientJside, perhaps to handle user input, manipulate a web page’s DOM, or induce subsequent HTTP requests. PHP should be used when you want to execute code serverJside, perhaps to handle a form’s submission, generate HTML, or write to a database
500
What does this function do?
void* foo(void* a, char b)
{
    return &a[b];
}
it adds the numbers a and b
M
e
n
u