Jump to content
Larry Ullman's Book Forums

bshirey44

Members
  • Posts

    9
  • Joined

  • Last visited

Posts posted by bshirey44

  1. Hello Everyone,

     

    I am suddenly experiencing an issue with the billing.php script.  Once the checkout form is validated it redirects to billing.php.  The problem seems to be that once billing.php starts the session, it is getting a different session_id and then gets out at the top and ends up at the empty cart screen because it has lost the previous session values thus preventing the checkout process from completing.  I am stumped as to how this is happening.  Here is the code from the top of billing.php where it gets out:

     

    // Require the configuration before any PHP code:
    require ('./includes/config.inc.php');
    
    // Start the session:
    session_start();
    
    // The session ID is the users cart ID:
    $uid = session_id();
    
    // Check that this is valid:
    if (!isset($_SESSION['customer_id'])) { // Redirect the user.
    
    $location = 'https://' . BASE_URL . 'checkout.php';
    header("Location: $location");
    exit();
    }
    

    it is not finding the $_SESSION['customer_id'] which is being set correctly in checkout.php but is being whiped out somehow.  Any help is much appreciated.  Thanks.

     

  2. <?php
    // This function will take $_SERVER['REQUEST_URI'] and build a breadcrumb based on the users current path
    function breadcrumbs($separator = ' » ', $home = 'Home') {
       // This gets the REQUEST_URI (/path/to/file.php), splits the string (using '/') into an array, and then filters out any empty values
       $path = array_filter(explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)));
       // This will build our "base URL" ... Also accounts for HTTPS 
      $base = 'http' . '://' . $_SERVER['HTTP_HOST'] . '/';
       // Initialize a temporary array with our breadcrumbs. (starting with our home page, which I'm assuming will be the base URL)
       $breadcrumbs = Array("<a href=\"$base\">$home</a>");
       // Find out the index for the last value in our path array
       $keys = array_keys($path);
       $last = end($keys);
       // Build the rest of the breadcrumbs
       foreach ($path AS $x => $crumb) {
        // Our "title" is the text that will be displayed (strip out .php and turn '_' into a space)
        $title = ucwords(str_replace(Array('.php', '_'), Array('', ' '), $crumb));
        // If we are not on the last index, then display an <a> tag
        if ($x != $last)
    	    $breadcrumbs[] = "<a href=\"$base$crumb\">$title</a>";
        // Otherwise, just display the title (minus)
        else
    	    $breadcrumbs[] = $title;
       }
       // Build our temporary array (pieces of bread) into one big string 
       return implode($separator, $breadcrumbs);
    }
    

  3. I was attempting to add a crumb trail to my site that is being modeled after the second example from the book. I am new to web development and php. I found lots of examples of php crumb trails on google, but they don't quite work well with this site. I was wondering if anyone has added this functionality to a site based on the second example and if so would you mind sharing? Thanks.

×
×
  • Create New...