Chapter 7 Flashcards
I want to add new columns to my database. What would I use here: _____ _____ mismatch_user ADD username VARCHAR(32) NOT NULL AFTER user_id, ADD password VARCHAR(40) NOT NULL AFTER username;
ALTER TABLE ALTER TABLE mismatch_user ADD username VARCHAR(32) NOT NULL AFTER user_id, ADD password VARCHAR(40) NOT NULL AFTER username;
What does SHA() stand for?
Secure Hash Algorithm
What is SHA() used for?
- SHA() is used to encrypt data inserted into a table using the Secure Hash Algorithm
- SHA() create a 40 character hexadecimal encrypted string using a one way encryption scheme
SHA() create a 20 character hexadecimal encrypted string using a two way encryption scheme.
True or False?
False:
SHA() creates a 40 character hexadecimal encrypted string using a one way encryption scheme.
True or False
SHA() creates a 40 character hexadecimal encrypted string using a one way encryption scheme.
True
True or False:
mysqli_real_escape_string() is used to protect against SQL injection attacks by escaping special characters in a string used for an SQL statement.
True
$user_username = mysqli_real_escape_string($dbc, trim($_SERVER[‘PHP_AUTH_USER’]));
$user_password = mysqli_real_escape_string($dbc, trim($_SERVER[‘PHP_AUTH_PW’]));
What does the mysqli_real_escape_string() function do?
mysqli_real_escape_string() is used for escaping special characters in a string used for anSQL statement.
What does the trim() function do?
The trim() function trimms whitespace from either end of the string.
What are the components of a cookie?
- Name
- Value
- Expiration Date
A cookie will last forever. True or False?
False, a cookie will last as long as it’s set expiration date.
If the expiration date is not set, it will last until the user dismisses the browser session.
What do cookies do?
Cookies allow the persistance of small pieces of data on the client that have a time limit and can be deleted at will.
What does the function setcookie() do?
setcookie() allows you to set the name, value, and expiration of a cookie.
setcookie(‘username’, ‘kenmarks’);
setcookie(‘user_id’, ‘1’);
$_COOKIE does what?
$_COOKIE is a superglobal used to retrieve the value of a cookie.
echo ‘
You are logged in as ‘ . $_COOKIE[‘username’] . ‘.
’;
True or False:
Using cookies for log-in means that you can also use the HTTP Authorization header
False:
Using Cookies for log-in information means you cannot use the HTTP Authorization header
True or False:
Using Cookies for log-in information means you cannot use the HTTP Authorization header
True.
How do you use cookies to log a user out?
setcookie()
Use setcookie() to set back the time which forces the deletion of the Cookie
setcookie(‘username’, ‘kemarks’, time() - 3600);
What doe sthe following code do:
setcookie(‘username’, ‘kemarks’, time() - 3600);
Sets back the time by one hour to log the user out.