Jump to content
Larry Ullman's Book Forums

buckeye

Members
  • Content Count

    17
  • Joined

  • Last visited

Community Reputation

0 Neutral

About buckeye

  • Rank
    Newbie
  1. Hello, I am a regularly reader of your books, which have been very helpful and self-explanatory. However, I've ran into an issue I can't seem to figure out: I am trying to use the pagination from Chapter 10 and been successful in the past. Now, I need to use it a modularized site with mod_rewrite (adapted from your technique in PHP Advanced, Chapter 10). There are 52 records, which are consistent with my $display = 10; and $subcategoryShort = 'beds'; The links display as 1 2 3 4 5 Next (/our-furniture-test/beds/20/5/) My links appear to be correct, however, I get the
  2. This is an adaptation of the view_cart.php script in ch 19. It had worked previously until I changed servers/web hosting. It may be coincidental, however, when changing cart quantity to zero, it will either throw an error (undefined total variable) or add additional products to cart which were previously deleted in the same session. All other functions work propertly, including "add to cart" and "checkout" when quantities are not changed to zero. Any suggestions would be greatly appreciated. <div class="generalarticle"> <?php // add_cart.php $cart = $_SESSION['cart']; // Ch
  3. 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 ca
  4. RewriteRule (product-detail)/([^/]*)/$ /index.php?p=$1&id=$2 [L] RewriteCond %{QUERY_STRING} id=([0-9]+) I believe I've solved this issue by including the above lines in the .htaccess file. It now redirects the indexed product id pages to the new, modularized pages.
  5. I am modularizing a existing site as discussed in Chapter 2. All is working fine but I cannot seem to find the correct rewrite script for my .htaccess relative to rewriting (or forwarding existing) links that have been indexed in search engines. An example: http://www.example/productdetail.php?id=100 (as indexed by Google) should display as http://www.example/product-detail/100/ but instead is displaying in address bar as http://www.example/product-detail/?id=100 (and obviously no page is found) My current .htaccess is: RewriteEngine On RewriteRule ^([^/]*)/$ /index
  6. Thank you for your response. The mod_rewrite is working for all other pages, except for the activation page/module. It definitely is set-up and available on the server.
  7. <?php // script 18.6 if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form. // Need the database connection: require (MYSQL); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $fn = $ln = $e = $p = FALSE; // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['first_name'])) { $fn = mysqli_real_escape_string ($dbc, $trimmed['first_name']); } else { echo '<p class="error">Please enter your first name!</p>'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $trimm
  8. Thank you, HartleySan, for your response. Very helpful! This solved an issue I was having while modularizing a site.
  9. // Query the database: $q = "SELECT * FROM users WHERE email='$e' AND active IS NULL"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); } include('includes/lib/password.php'); $hash=password_hash($p, PASSWORD_BCRYPT); if (password_verify($pass, $hash)) { // Correct! Thought I had this figured out. The logic in the previous response (though it included the password_verify) was incorrect. This modified excerpt of the script allows login (by checking for e-mail) but is not checking password. Any suggestions wou
  10. <?php # Script 18.8 - login.php // This is the login page for the site. require ('includes/config.inc.php'); $page_title = 'Login'; include ('includes/header.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { require (MYSQL); // Validate the email address: if (!empty($_POST['email'])) { $e = mysqli_real_escape_string ($dbc, $_POST['email']); } else { $e = FALSE; echo '<p class="error">You forgot to enter your email address!</p>'; } // Validate the password: if (!empty($_POST['pass'])) { $p = mysqli_real_escape_string ($dbc, $_POST['pass']); } else { $p =
  11. <?php # Script 18.8 - login.php // This is the login page for the site. require ('includes/config.inc.php'); $page_title = 'Login'; include ('includes/header.html'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { require (MYSQL); // Validate the email address: if (!empty($_POST['email'])) { $e = mysqli_real_escape_string ($dbc, $_POST['email']); } else { $e = FALSE; echo '<p class="error">You forgot to enter your email address!</p>'; } // Validate the password: if (!empty($_POST['pass'])) { $p = mysqli_real_escape_string ($dbc, $_POST['pass']); } else { $p =
  12. Issue was resolved. Found error in config file related to definition of constants. Thanks.
  13. <?php // This is the registration page for the site. // This file both displays and processes the registration form. // This script is begun in Chapter 4. // Require the configuration before any PHP code as the configuration controls error reporting: require('includes/config.inc.php'); // The config file also starts the session. // Require the database connection: require(MYSQL); // Include the header file: $page_title = 'Register'; include('includes/header.html'); // For storing registration errors: $reg_errors = array(); // Check for a form submission: if ($_SERVER['REQUEST_METHOD']
  14. I was able to correct the issue in which an error message was reported. However, the problem remains that once I complete the registration form and click submit, I remain on the registration page and no "thank you" message is given. Likewise, I check the database and obviously a user hasn't been added.
  15. I am having a problem with the registration page in Chapter 4, Example 1. When I complete the registration form, a simply get a blank page below the header. It stays on register.php and does not advance to thankyou.php. Error checking indicates an undefined index for all the variables. Not sure why that is happening, as I am using the script from the book. Any suggestions would be appreciated.
×
×
  • Create New...