Search the Community
Showing results for tags 'chapter 2'.
-
Hi everybody, I'm dusting off my PHP with this book. I'm using a kindle edition. In chapter 2 I can read: $months = [1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; This doesn't work for me (PHP 5.3.1) I think it should read: $months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
-
I have a modularized site in which all pages flow through the index.php. Login/logout works fine using sessions, in which a administrative level user must be logged for the "Admin" menu icon to appear in the menu. I have placed the 'admin' directory inside the 'module' directory. When a logged in user clicks "Admin," I am having difficulty preventing it from running the script (and thereby displaying the admin page) without first requiring a login. I have confirmed the directory is protected from direct access but not from running it. I know it must be a permissions setting, however, I cannot find what the correct permissions need to be. Is this possible? Below is the 'case' to load the admin panel over the index.php (again, the 'admin' directory is within the 'modules' directory): case 'admin-panel': $page = 'admin/admin-panel.inc.php'; $page_title = 'Admin Panel'; break; I can avoid this by simply having an admin_panel.php or index.php within a password protected 'admin' directory, however, I would like to keep the modular pattern and maintain the admin accessibility through the menu. Any suggestions would be appreciated.
- 1 reply
-
- modular site
- admin page
-
(and 2 more)
Tagged with:
-
"will make it easier to refer to the variables when printing them" When who is printing them? the browser? and p 14 "To display the value of a variable, you can print the variable without quotation marks:" Meaning, I can ask the browser to print the variable? Or, I can type the variable (key) the variable w/o quotation marks? and then what do you mean by "you can print the variable without quotation marks" I mean-
-
I just started going through the book and ran into my first problem while working through the end of chapter 2 in the Pursue section: The relevant part of Script 2.4 is: if (isset($_POST['gender'])) { $gender = $_POST['gender']; if ($gender == 'M') { echo '<p><b>Good day, Sir!</b></p>'; } elseif ($gender == 'F') { echo '<p><b>Good day, Madam!</b></p>'; } else { $gender = NULL; echo '<p class="error"><b>Gender should be either M or F!</b></p>'; } } else { $gender = NULL; echo '<p class="error"><b>You forgot to select your gender!</b></p>'; } I am using 'yes' and 'no' instead of 'M' and 'F' but this is the code that I used: if(isset($_POST['newsletter']) == 'yes') { echo "<p>Thank you for signing up for our monthly newsletter!</p>"; } elseif(isset($_POST['newsletter']) == 'no') { echo "<p>We are sorry you have decided NOT to sign up for our newsletter.</p>"; } else { echo "<p>You for got to choose a newsletter option!</p>"; } I know the hint suggested that I use the AND operator. The above code seems like it should work but ifelse(or the 'no') is printing the same as the if(or the 'yes') response and the else(where nothing is checked) is printing the correct response. In other words, When no is checked on the form it is saying "thank you for signing up" instead of "sorry you have decided to NOT..."
- 2 replies
-
- chapter 2
- if statement
-
(and 1 more)
Tagged with: