WIP400 - Programming for Designers:
Mid-Term & Final PRACTICE QUESTIONS
Multiple Choice (10 x 2.5 points each):
Circle the option that best answers each question.
- How do you write a comment in PHP?
- /* */
- All of the above
- The logical operator && checks for what?
- If either or both arguments are true.
- If both arguments are true.
- If one, but not both arguments are true.
- If none of the arguments are true.
- Immediately after sending a form with the attribute method=”post”, the data can be accessed via:
- $_SESSION superglobal array
- $_GET or $_POST superglobal arrays
- $_POST or $_REQUEST superglobal arrays
- $_SESSION, $_GET and $_POST superglobal arrays
True / False (10 x 2.5 points each):
- The isset() function can be used to check if a variable has been defined.
- You don’t need to sanitize your form data, the server will automatically escape any dangerous user input.
- A JOIN is when you write a SELECT statement that involves multiple tables
Hand Coded Problems (5 x 10 points each). Use the provided code as a starting point. You do not need to escape into PHP:
- Using an IF statement, finish the code below to display the message if the user’s score is at least 5,000.
$message = ‘You won the game!’;
$score = $_REQUEST[‘score’];
- Finish the code below to redirect the user to the file ‘secret-page.php’ if they are logged in. The session variable ‘loggedin’ will be true if they are logged in.
$logged_in = $_SESSION[‘loggedin’];
Note: the following questions will use this table as a reference.
You only need to write the SQL statements, no PHP is necessary.
Table name: comments
I love this post! great job, you.
Hmm, I don't think I agree
It's taco tuesday today!
- Write an SQL statement to retrieve the date and body fields of all comments written by user 1, oldest comment first.
- Write an SQL statement to add the following comment to the comments table:
Date: (get the current date)
Body: Happy St. Pats Day!