Jump to content
Larry Ullman's Book Forums

Rob_On_LU_Forum

Members
  • Posts

    12
  • Joined

  • Last visited

Recent Profile Visitors

908 profile views

Rob_On_LU_Forum's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Larry I believe I have figured out my issue. I will use the following to check for a value in the $_GET array and assign a blank string if not. When I add this code on cart.php BEFORE line 43 shown above, I no longer get the Undefined Index notice. Thanks for hanging in there with me on this post. $handle_length = isset($_GET['handle_length']) ? $_GET['handle_length'] : ''; $rope_length = isset($_GET['rope_length']) ? $_GET['rope_length'] : ''; $rope_gauge = isset($_GET['rope_gauge']) ? $_GET['rope_gauge'] : ''; $handle_color = isset($_GET['handle_color']) ? $_GET['handle_color'] : ''; $end_cap_color = isset($_GET['end_cap_color']) ? $_GET['end_cap_color'] : ''; $shirt_size = isset($_GET['shirt_size']) ? $_GET['shirt_size'] : ''; $hat_size = isset($_GET['hat_size']) ? $_GET['hat_size'] : '';
  2. Here is line 43 $r = mysqli_query($dbc, "INSERT INTO carts (user_session_id, product_type, product_id, quantity, handle_length, rope_length, rope_gauge, handle_color, end_cap_color, shirt_size, hat_size) VALUES ('$uid', '$sp_type', $pid, 1, '".$_GET['handle_length']."', '".$_GET['rope_length']."', '".$_GET['rope_gauge']."', '".$_GET['handle_color']."', '".$_GET['end_cap_color']."', '".$_GET['shirt_size']."', '".$_GET['hat_size']."')"); This code will produce the Undefined Index error when the [_GET] Array does not contain each of the column => value pairs it is looking for. I have separate view files; one for jump ropes, one for hats, one for shirts. So if the user adds a shirt to the cart from the shirts html view file for example, the _GET array does not contain a jumprope $_GET['handle_length'] option value and the Undefined Index error is produced. I have these pages on a testing server and I could provide the URL but I am not sure if you have the bandwidth to check that out right now.
  3. PHP version is 5.4.10 The error message is: An error occurred in script '/Applications/MAMP/htdocs/cart.php' on line 43: Undefined index: handle_length To debug I am using <pre><?php print_r($_GET); ?></pre> to monitor the arrays to make sure my select statements are working when going from browse.php to the html view pages. The database has the same structure as described in the book with two additional tables for my product options which are named options and option_groups. I think the problem is that my INSERT INTO carts statement on cart.php, includes columns and values that are not a <option value> on every html view file. So I need to somehow put a conditional on INSERT INTO carts statement that only attempts to add to the carts table based on the <option value> from the html view page the user is on when submitting. These questions are probably too localized and ambiguous. Especially for a Sunday morning so no worries if this post needs to be closed!
  4. I am following the ex.2 sample code that comes with Part Three Selling Physical Products chapters of the Effortless E-Comm book. I have added product options to the items to be sold on the site I am building. All of my stored procedures are working correctly, selecting the product options I created. My browse.php and html view files are working correctly with the htaccess file as I can browse between /shop/ and /browse/ correctly on my localhost and see the product options on each html view file. The issue I ran into at this point is getting the undefined variable notices or warnings when the html view files "pass" the result set to my cart.php page. It appears to me that because I have all the 'jumprope' (jumprope versus coffee) and 'other' select results in ONE fetch array coming from browse.php then the html view files into cart.php, I get an Undefined index error. So I need to make a change to the cart.php page so that there is some type of conditional put on the add_to_cart INSERT procedure. I am using Larry's Rewrite of the Stored Procedures using PHP instead of the stored procedure for the add_to_cart procedure until I get this squared away. Because the only the individual product options are shown on the html view pages, the other category product options are not in the result set cart.php uses in the first add_to_cart SELECT, UPDATE, INSERT statement. Hence I get the Undefined error. And with the code written as pasted below, this is normal and correct. What I mean is that if cart.php is coming from list_customRope.html, there is no 'shirt_size' in the $r = mysqli_query, and the undefined index error or warning come up. If I remove the 'other' columns and values from the add_to_cart INSERT statement shown on cart.php (hat and shirt sizes), my cart table is updated correctly when coming from listcustomRopes.html. It is hard to explain this so I completely understand if this is too open ended. I have my browse.php page, the list_customRope.html page and cart.php page included below in case one of the forum leaders would have any advice. As always thank you for reading my post. ---------------------- browse.php ------ ---------------------- <?php // This file lists products in a specific category // This script is begun in Chapter 8. // Require the configuration before any PHP code: require ('./includes/config.inc.php'); // Validate the required values: $type = $sp_type = $sp_cat = $category = false; if (isset($_GET['type'], $_GET['category'], $_GET['id']) && filter_var($_GET['id'], FILTER_VALIDATE_INT, array('min_range' => 1))) { // Make the associations: $category = $_GET['category']; $sp_cat = $_GET['id']; // Validate the type: if ($_GET['type'] == 'goodies') { $sp_type = 'other'; $type = 'goodies'; } elseif ($_GET['type'] == 'jumprope') { $type = $sp_type = 'jumprope'; } } // If there's a problem, display the error page: if (!$type || !$sp_type || !$sp_cat || !$category) { $page_title = 'Error!'; include ('./includes/header.html'); include ('./views/error.html'); include ('./includes/footer.html'); exit(); } // Create a page title: $page_title = ucfirst($type) . ' to Buy::' . $category; // Include the header file: include ('./includes/header.html'); // Require the database connection: require (MYSQL); // Call the stored procedure: $have_results=false; $r = mysqli_query($dbc, "CALL select_products('$sp_type', $sp_cat)"); if($r and mysqli_num_rows($r)) { $have_results=true; } mysqli_next_result($dbc); if ($sp_type=="jumprope") //santity check to see what $sp_type contains echo "the sp_type is $sp_type"; else echo "the sp_type is $sp_type"; $r_handle = mysqli_query($dbc, "CALL select_handle_length ('jumprope');"); //var_dump("1");var_dump($r_handle);var_dump(mysqli_num_rows($r_handle)); if($r_handle and mysqli_num_rows($r_handle)>0) { $have_results=true; } mysqli_next_result($dbc); $r_rope_length = mysqli_query($dbc, "CALL select_rope_length ('jumprope');"); //var_dump("2");var_dump($r_rope_length);var_dump(mysqli_num_rows($r_rope_length)); if($r_rope_length and mysqli_num_rows($r_rope_length)>0) { $have_results=true; } mysqli_next_result($dbc); $r_rope_gauge = mysqli_query($dbc, "CALL select_rope_gauge ('jumprope');"); //var_dump("3");var_dump($r_rope_gauge);var_dump(mysqli_num_rows($r_rope_gauge)); if($r_rope_gauge and mysqli_num_rows($r_rope_gauge)>0) { $have_results=true; } mysqli_next_result($dbc); $r_handle_color = mysqli_query($dbc, "CALL select_handle_color ('jumprope');"); //var_dump("4");var_dump($r_handle_color);var_dump(mysqli_num_rows($r_handle_color)); if($r_handle_color and mysqli_num_rows($r_handle_color)>0) { $have_results=true; } mysqli_next_result($dbc); $r_endcap_color = mysqli_query($dbc, "CALL select_endcap_color ('jumprope');"); //var_dump("5");var_dump($r_endcap_color);var_dump(mysqli_num_rows($r_endcap_color)); if($r_endcap_color and mysqli_num_rows($r_endcap_color)>0) { $have_results=true; } mysqli_next_result($dbc); $r_shirt_size = mysqli_query($dbc, "CALL select_shirt_size ('other');"); //var_dump("5");var_dump($r_shirt_size);var_dump(mysqli_num_rows($r_shirt_size)); if($r_shirt_size and mysqli_num_rows($r_shirt_size)>0) { $have_results=true; } mysqli_next_result($dbc); $r_hat_size = mysqli_query($dbc, "CALL select_hat_size ('other');"); //var_dump("5");var_dump($r_hat_size);var_dump(mysqli_num_rows($r_hat_size)); if($r_hat_size and mysqli_num_rows($r_hat_size)>0) { $have_results=true; } mysqli_next_result($dbc); mysqli_close($dbc); // For debugging purposes: if (!$r) echo mysqli_error($dbc); // If records were returned, include the view file NOTE: Added: if (mysqli_num_rows($r) > 0) { if ($category == "Tee-Shirts") { // Three versions of this file: include ('./views/list_teeShirts.html'); } elseif ($category == "Hats") { include ('./views/list_hats.html'); } elseif ($category == "Pre-Built Dynamite Stick") { include ('./views/list_prebuiltRope.html'); } elseif ($category == "Customized Dynamite Stick") { include ('./views/list_customRope.html'); } } else { // Include the "noproducts" page: include ('./views/noproducts.html'); } // Include the footer file: include ('./includes/footer.html'); ?> ---------------------- listcustomRope.html ------ ---------------------- <?php // This page is included by browse.php. // This page displays the available Customized Jump Rope products. // This page will make use of the query result $r. // The query returns an array of: description, image, sku, name, and stock. // Only display the header once: $header = false; // Added later in Chapter 8: include ('./includes/product_functions.inc.php'); // Loop through the results: while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { // If the header hasn't been shown, create it: if (!$header) { ?> <!-- box begin --> <div class="box alt"> <div class="left-top-corner"> <div class="right-top-corner"> <div class="border-top"></div> </div> </div> <div class="border-left"> <div class="border-right"> <div class="inner"> <h2><?php echo $category; ?></h2> <div class="img-box"> <p><img alt="<?php echo $category; ?>" src="/products/<?php echo $row['image']; ?>" /><?php echo $row['description']; ?></p> <p><small>All listed products are currently available.</small> <form action="/cart.php" method="get"><input type="hidden" name="action" value="add" /><select name="sku"> <?php // The header has now been shown: $header = true; } // End of $header IF. // Create each option: echo '<option value="' . $row['sku'] . '">' . $row['name'] . get_price($type, $row['price'], $row['sale_price']) . '</option>'; } // End of WHILE loop. if($header) ?> </select><br /> <?php $header = false; // Loop through the results: if($r_handle) { while ($row = mysqli_fetch_array($r_handle, MYSQLI_BOTH)) { // If the header hasn't been shown, create it: if (!$header) { ?> Handle Length <select name="handle_length"> <?php // The header has now been shown: $header = true; } // End of $header IF. // Create each option: echo '<option value="' . $row['handle_length'] . '">' . $row['handle_length'] . ' </option>'; } // End of WHILE loop. if($header) { } } ?> </select><br /> <?php $header = false; // Loop through the results: if($r_handle) { while ($row = mysqli_fetch_array($r_rope_length, MYSQLI_ASSOC)) { // If the header hasn't been shown, create it: if (!$header) { ?> Rope Length <select name="rope_length"> <?php // The header has now been shown: $header = true; } // End of $header IF. // Create each option: echo '<option value="' . $row['rope_length'] . '">' . $row['rope_length'] . '</option>'; } // End of WHILE loop. if($header) { } } ?> </select><br /> <?php $header = false; // Loop through the results: if($r_rope_gauge) { while ($row = mysqli_fetch_array($r_rope_gauge, MYSQLI_ASSOC)) { // If the header hasn't been shown, create it: if (!$header) { ?> Rope Gauge <select name="rope_gauge"> <?php // The header has now been shown: $header = true; } // End of $header IF. // Create each option: echo '<option value="' . $row['rope_gauge'] . '">' . $row['rope_gauge'] . '</option>'; } // End of WHILE loop. if($header) { } } ?> </select><br /> <?php $header = false; // Loop through the results: if($r_handle_color) { while ($row = mysqli_fetch_array($r_handle_color, MYSQLI_ASSOC)) { // If the header hasn't been shown, create it: if (!$header) { ?> Handle Color <select name="handle_color"> <?php // The header has now been shown: $header = true; } // End of $header IF. // Create each option: echo '<option value="' . $row['handle_color'] . '">' . $row['handle_color'] . '</option>'; } // End of WHILE loop. if($header) { } } ?> </select><br /> <?php $header = false; // Loop through the results: if($r_handle) { while ($row = mysqli_fetch_array($r_endcap_color, MYSQLI_ASSOC)) { // If the header hasn't been shown, create it: if (!$header) { ?> End Cap Color <select name="end_cap_color"> <?php // The header has now been shown: $header = true; } // End of $header IF. // Create each option: echo '<option value="' . $row['end_cap_color'] . '">' . $row['end_cap_color'] . '</option>'; } // End of WHILE loop. if($header) { } } ?> </select><br /> <p>Quantity<select name="qty"><option>1</option><option>2</option><option>3</option></select></p> </select> <input type="submit" value="Add to Cart" class="button" /></p></form></div> </div> </div> </div> <div class="left-bot-corner"> <div class="right-bot-corner"> <div class="border-bot"></div> </div> </div> </div> <!-- box end --> ---------------------- cart.php ------ ---------------------- <?php // This file manages the shopping cart. // This script is begun in Chapter 9. // Require the configuration before any PHP code: require ('./includes/config.inc.php'); // Check for, or create, a user session: if (isset($_COOKIE['SESSION'])) { $uid = $_COOKIE['SESSION']; } else { $uid = md5(uniqid('biped',true)); } // Send the cookie: setcookie('SESSION', $uid, time()+(60*60*24*30)); // Include the header file: $page_title = '1st JumpRope goes to Larry Ullman'; include ('./includes/header.html'); // Require the database connection: require (MYSQL); // Need the utility functions: include ('./includes/product_functions.inc.php'); // If there's a SKU value in the URL, break it down into its parts: if (isset($_GET['sku'])) { list($sp_type, $pid) = parse_sku($_GET['sku']); } if (isset ($pid, $sp_type, $_GET['action']) && ($_GET['action'] == 'add') ) { // Add a new product to the cart: //$r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, 1)"); $r = mysqli_query($dbc, "SELECT id FROM carts where user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); if (mysqli_num_rows($r) == 1) { // Exists in cart, UPDATE! list($cid) = mysqli_fetch_array($r, MYSQLI_NUM); $r = mysqli_query($dbc, "UPDATE carts SET quantity=quantity+1, date_modified=NOW() WHERE id=$cid"); } else { // Not in cart, INSERT! $r = mysqli_query($dbc, "INSERT INTO carts (user_session_id, product_type, product_id, quantity, handle_length, rope_length, rope_gauge, handle_color, end_cap_color, shirt_size, hat_size) VALUES ('$uid', '$sp_type', $pid, 1, '".$_GET['handle_length']."', '".$_GET['rope_length']."', '".$_GET['rope_gauge']."', '".$_GET['handle_color']."', '".$_GET['end_cap_color']."', '".$_GET['shirt_size']."', '".$_GET['hat_size']."')"); } // For debugging purposes: if (!$r) echo mysqli_error($dbc); } elseif (isset ($sp_type, $pid, $_GET['action']) && ($_GET['action'] == 'remove') ) { // Remove it from the cart. $r = mysqli_query($dbc, "CALL remove_from_cart('$uid', '$sp_type', $pid)"); } elseif (isset ($sp_type, $pid, $_GET['action'], $_GET['qty']) && ($_GET['action'] == 'move') ) { // Move it to the cart. // Determine the quantity: $qty = (filter_var($_GET['qty'], FILTER_VALIDATE_INT, array('min_range' => 1))) ? $_GET['qty'] : 1; // Add it to the cart: $r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, $qty)"); // Remove it from the wish list: $r = mysqli_query($dbc, "CALL remove_from_wish_list('$uid', '$sp_type', $pid)"); } elseif (isset($_POST['quantity'])) { // Update quantities in the cart. // Loop through each item: foreach ($_POST['quantity'] as $sku => $qty) { // Parse the SKU: list($sp_type, $pid) = parse_sku($sku); if (isset($sp_type, $pid)) { // Determine the quantity: $qty = (filter_var($qty, FILTER_VALIDATE_INT, array('min_range' => 0)) !== false) ? $qty : 1; // Update the quantity in the cart: $r = mysqli_query($dbc, "CALL update_cart('$uid', '$sp_type', $pid, $qty)"); } } // End of FOREACH loop. }// End of main IF. // Get the cart contents: $r = mysqli_query($dbc, "CALL get_shopping_cart_contents('$uid')"); if (mysqli_num_rows($r) > 0) { // Products to show! include ('./views/cart.html'); } else { // Empty cart! include ('./views/emptycart.html'); } // Finish the page: include ('./includes/footer.html'); ?>
  5. I am attempting to use mysqli_multi_query on 5 SELECT stored routines. My goal is to use <option></option> values for 5 drop down product select lists on my site. Using the printf and the later print_r functions I can see the $row[2] $query results at the top of my list_rope_options6.html page, and the results are correct, in that mysqli_multi_query is indeed returning the correct number of rows from my tables. However I get the error: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given when the program loops through the results while command, which I have as while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) I remember Larry writing in PHP and MySQL For Dynamic Web Sites that he sometimes see beginning PHP developers muddle the process of fetching query results, and I am newbie playing in the mud, probably making this too hard by using the mysqli_multi_query! But before I move back to running the SELECT routines one at a time I thought I would post the code and this question. Will mysqli_fetch_array work with the mysqli_multi_query in order to use fetch_array on the <option> lists? I have tried other mysqli_fetch_array() Constants _ASSOC, _NUM and _BOTH but I continue to get the same error, string given. I get stuck because using the printf then print_r functions I can see the correct results, (all the rows the 5 SELECT routines should return, are being returned) but while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) is resulting in a string which I guess can not be used on the <option> select options as written. Cross fit speed jump ropes will be sold (eventually) and this is a hobby side project! Here is my testing php page named index6.php. At the very bottom is the first part of my_error_handler <?php require ('./config.inc.php'); require ('./mysql.inc.php'); $query = "CALL select_handle_length ('jumprope');"; $query .= "CALL select_rope_length ('jumprope');"; $query .= "CALL select_rope_gauge ('jumprope');"; $query .= "CALL select_handle_color ('jumprope');"; $query .= "CALL select_endcap_color ('jumprope');"; /* execute multi query */ if (mysqli_multi_query($dbc, $query)) { do { // store first result set if ($result = mysqli_use_result($dbc)) { while ($row = mysqli_fetch_row($result)) { printf("%s\n", $row[2]); } mysqli_free_result($result); } /* print divider */ if (mysqli_next_result($dbc)) { print_r("--\n"); } } while (mysqli_more_results($dbc)); include ('./list_rope_options6.html'); } mysqli_close($dbc); ?> -- ------------------ And here is the ./list_rope_options6.html page which is not styled, only one <option value> set at this point...----------------------- -- <?php // This page is included by index6.php. // This page displays the available jumprope options. // This page will make use of the query result $query. // The query returns an array of: option_name. // Only display the header once: $header = false; // Loop through the results: while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { // If the header hasn't been shown, create it: if (!$header) { ?> <form action="./index6.php" method="get"><input type="hidden" name="action" value="add" /><select name="Handle Length"> <?php // The header has now been shown: $header = true; } // End of $header IF. // Create each option: echo '<option value="' . $row['id'] . '">' . $row['Handle Length'] . '</option>'; } // End of WHILE loop. ?></select> <input type="submit" value="Add to Cart" class="button" /></p></form></div> </div> </div> </div> <div class="left-bot-corner"> <div class="right-bot-corner"> <div class="border-bot"></div> </div> </div> </div> <!-- box end --> -- ----------------- The Error Array ------------------- -- 6 inch 7 inch 8 inch -- -- 6 ft 6 ft 3 in 6 ft 6 in 6 ft 9 in 7 ft 7 ft 3 in 7 ft 6 in 7 ft 9 in 8 ft 8 ft 3 in 8 ft 6 in 8 ft 9 in 9 ft 9 ft 3 in 9 ft 6 in 9 ft 9 in 10 ft 10 ft 3 in 10 ft 6 in 10 ft 9 in 11 ft enter -- -- 3/32 in 3/64 in 1/16 in -- -- Maroon Black Pink Red Blue Yellow Green Purple Orange Teal/Light Blue Lime Green -- -- Brown Gray White Purple Yellow Orange Green Red Blue -- An error occurred in script '/Applications/MAMP/WORKING_SITES/productOptionTesting/list_rope_options6.html' on line 11: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given Array( [0] => Array ( [function] => my_error_handler [args] => Array ( [0] => 2 [1] => mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given [2] => /Applications/MAMP/WORKING_SITES/productOptionTesting/list_rope_options6.html [3] => 11 [4] => Array ( [_GET] => Array ( ) [_POST] => Array ( ) [_COOKIE] => Array ( ) [_FILES] => Array ( ) [live] => [contact_email] => you@example.com [dbc] => mysqli Object ( [affected_rows] => 0 [client_info] => 5.5.29 [client_version] => 50529 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 0 [host_info] => Localhost via UNIX socket [info] => [insert_id] => 0 [server_info] => 5.5.29 [server_version] => 50529 [stat] => Uptime: 7805 Threads: 1 Questions: 1686 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.216 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 106 [warning_count] => 0 ) [query] => CALL select_handle_length ('jumprope');CALL select_rope_length ('jumprope');CALL select_rope_gauge ('jumprope');CALL select_handle_color ('jumprope');CALL select_endcap_color ('jumprope'); [result] => mysqli_result Object
  6. Thanks for explanation Larry. So would I be correct then to say that in order to set up the FK's on the coffee tables as described in the book, the tables would need to use InnoDB? I notice the books ex2.sql database script does use MyISAM for the coffee tables but the chapter discusses using foreign keys on them, so this is what brought me to ask the question.
  7. Thank you forum leaders in advance for reading my topic. My question relates to the foreign keys on the non_coffee_products table shown in Figure 7.3 I can see that the non_coffee_category_id column is the foreign key referenced to non_coffee_category_id in the non_rope_categories table. ( I notice the downloadable sql script for the book does not include the FOREIGN KEY statements, or as far as I can tell they are not included). So I added this foreign key as: CREATE TABLE `non_coffee_products` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `non_coffee_category_id` tinyint(3) unsigned NOT NULL, `name` varchar(60) NOT NULL, `description` tinytext, `image` varchar(45) NOT NULL, `price` decimal(5,2) unsigned NOT NULL, `stock` mediumint(8) unsigned NOT NULL DEFAULT '0', `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), KEY non_coffee_category_id (non_coffee_category_id), FOREIGN KEY (non_coffee_category_id) REFERENCES non_coffee_categories (id) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; When I view this script as a EER Diagram in MySQL Workbench, it looks right to this newbie... My question relates to the non_coffee_products and specific_coffee tables relationship to the sales table. Which column in the sales table should be referenced as the foreign keys to the non_coffee_products and specific_coffees tables? Once again thank you for reading my posts. It is very special in the communities we live in today that the forum leaders give their valued advice, for free and asking nothing in return. That is very special and I thank you.
  8. Thank you margaux. It makes sense to me to disable the checks for a logged in user or not expired account versus trying to "trick" system with the redirect_invalid user function. So I commented out code that does the logged in user/not expired validation on the following ex1 pages: category.php, page.php, view_pdf.php and pdfs.php. This will work perfect! Thanks again. Rob
  9. Would the forum leaders have a suggestion on how I could modify the ex1 Knowledge is Power code so that any visitor to the site can view the Content posted by the admin? In other words I would like to keep to the code in ex1 which enables Admin users to post content, however the change I look to make is that any visitor would have access to the posted content. (I understand ex1 is a subscription based website example, and I will re-write from scratch unless there is an "easy" change to the book code as written. I will use Larry's example in 'PHP and MySQL for Dynamic Web Sites' to set up the secure login site, and then add the Admin content features from the Effortless book!) But perhaps a change to the first variable in the redirect_invalid_user function could change from $check = 'user_id' to the current user's session variable 'php_sessid' so that any php_sessid (or other session variable I can set) allows access to the Admin's posted content. If this is too open ended, I completely understand. And I thank you for reading my post. Rob_on_LU_form
  10. Thanks you guys. I will go through Antonio's suggestions and find the root cause. Once I find my issue, I will update this post. Thanks again, Rob
  11. Good evening, Thank you in advance for reviewing my question regarding Part Two: Selling Virtual Products. I have completed Chapter 1 through 4 and my local site appears to be working correctly except for an important portion of these exercises, logging and logging out. I am able to create new users using the register.php page, and I can verify the new user is added by using phpmyadmin. All the links and the css style is being applied correctly to pages and the navigation links work correctly. However I can enter any characters in the Email Address and Password fields from the login side bar form, and after clicking submit I receive no error reports and the page is redirected to index.php, which is correct. But it does not appear there is actually a logged in user. So I am searching for what I have missed and thought perhaps Chapter 5 or beyond would introduce additional code that "enables" the validation for logging in registered users. But after starting Chapter 5, I believe I am missing something. If this question is too opened ended, I completely understand. I was thinking that this might be an issue with function redirect_invalid_user so I manually changed a user to Admin using myphpadmin, and added the session_regenerate_id code that Larry comments on at the end of Chapter 4. But for some reason it does not matter what characters are entered in the Email Address and Password fields as none of the expected text and pages are generated when these bogus entries are made. I will continue to search for my solution. I am enjoying the book and I am finding that it is a very effect learning tool. Thanks again, Rob
×
×
  • Create New...