Jump to content

aebstract

Members
  • Posts

    1,105
  • Joined

  • Last visited

Posts posted by aebstract

  1. function grabMemDetails (){
    
    global $db;
    $result = mysql_query("SELECT * FROM p_users WHERE id='$_SESSION[id]'") or DIE(mysql_error());
    
          while($r=mysql_fetch_array($result))
          {
    
          $email=$r["email"];
          $firstname=$r["firstname"];
          $lastname=$r["lastname"];
          $address=$r["address"];
          $city=$r["city"];
          $state=$r["state"];
          $zip=$r["zip"];
          $phone=$r["phone"];
          $pwhint=$r["pwhint"];
          $baddress=$r["baddress"];
          $bstate=$r["bstate"];
          $bcity=$r["bcity"];
          $bzip=$r["bzip"];
          $companyid=$r["companyid"];
          $middleinitial=$r["middleinitial"];
          $registerdate=$r["registerdate"];
    
          }
    
    }
    

     

     

    <?php
    session_start();
    header("Cache-control: private");
    if(!isset($_SESSION["id"]))
    {
    header("Location: index.php?page=login");
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    grabMemDetails();
    
    
    $content .= "<div id=\"full_content\">
    
    <p>Welcome, $firstname $lastname</p>
    
    </div>";
    
    
    
    ?>
    

     

    $firstname and $lastname are not displaying, any idea why?

  2. I was thinking this was a basic html issue, but I think it's in to the php. (may be wrong) It seems whenever I click my button to process the script, it won't finish through in IE but does fine in Firefox. Note that I am using an image as the submit button. Here is the page:

     

    <?php
    header("Cache-control: private");
    if(!isset($_SESSION["id"]))
    {
    header("Location: index.php?page=login");
    exit;
    }
    
    echo '<pre>', print_r($_POST), '</pre>';
    
    $product_cat = $_GET['product_cat'];
    $checknum = 1;
    $result = mysql_query("SELECT * FROM `p_products` WHERE category='$product_cat'") or DIE(mysql_error());
    while($r = mysql_fetch_array($result))
    {
      $id = $r['id'];
      $partnumber = $r['partnumber'];
      $partname = $r['partname'];
      $description = $r['description'];
      $price = $r['price'];
      $option1 = $r['option1'];
    $specialid = $id;
    
    $postname = image.$id;
    $postsize = size.$id;
    
    if (isset($_POST[$postname])) {
    $error = 0;
    if (isset($_POST['hideme'])) {
    if (empty($_POST[$postsize])){
    $error = 1;
    $errormsg = "You must fill in a Pipe Size for $partname.";
    } else {
    $sizenum = $_POST[$postsize];
    $specialid = $id.";".$sizenum;
    }
    
    
    
    
    
    }
    
    
    if ($error == 1){
    $errordisplay .= "<div id=\"error_box\">   $errormsg</div>";
    } else {
    
    
    
    $materialid = material.$id;
    $finishid = finish.$id;
    $material = $_POST[$materialid];
    $finish = $_POST[$finishid];
    
    
    
    if (isset($_SESSION['cart'][$id][$material][$finish])) {
    
    
    
    
      foreach ($_SESSION['cart'] as $id2 => $array2){
    
    		if ($id2 == $id) {
    
    		foreach ($array2 as $material2 => $array3){
    
    		if ($material2 == $material) {
    
    	foreach ($array3 as $finish2 => $array4){
    
    		if ($finish2 == $finish) {
    
    $newqty = $array4['qty'];
    $newqty ++;
    if (isset($array4['size'])) {
    $_SESSION['cart'][$id][$material][$finish] = array(qty => $newqty, size => $array4['size']);
    } else {
    $_SESSION['cart'][$id][$material][$finish] = array(qty => $newqty);
    }
    header("Location: index.php?page=cart");
    exit;
    
    }
    	}
    	   }
    
      }
               }
    
    
    
    
    
    
    
        	}
    
    
    
    
    
    
    } else {
    
    if (isset($_POST['hideme'])) {
    $setsize = size.$id;
    $_SESSION['cart'][$id][$material][$finish] = array(qty => 1, size => $_POST[$setsize]);
    } else {
    $_SESSION['cart'][$id][$material][$finish] = array(qty => 1);
    }
    header("Location: index.php?page=cart");
    exit;
    }
    }
    
    
    
    }
    
    
    if (!empty($option1)){
    $clicker = "
    <table>
    <tr><td align=\"right\">
    Material:
    </td><td>
    <select name=\"material$id\" style=\"background-color: #FFFFFF; border: solid 1px #000000; height: 20px; font-size: 10px;\">
    <option value=\"Stainless\">Stainless Steel</option>
    <option value=\"Mild\">Mild Steel</option>
    </select>
    </td></tr>
    <tr><td align=\"right\">
    Finish:
    </td><td>
    <select name=\"finish$id\" style=\"background-color: #FFFFFF; border: solid 1px #000000; height: 20px; font-size: 10px;\">
    <option value=\"Uncoated\">Uncoated</option>
    <option value=\"Black\">Black</option>
    <option value=\"Other\">Other</option>
    </select>
    </td></tr>
    <tr><td align=\"right\">
    Pipe Size:
    </td><td>
    <input type=\"text\" size=\"4\" value=\"\" name=\"size$id\" style=\"background-color: #FFFFFF; border: solid 1px #000000; height: 20px; font-size: 10px;\" /><br />
    </td></tr>
    </table>
    <div class=\"product_image\">
    <input type=\"hidden\" name=\"hideme\" value=\"needsize\" />
    <input type=\"image\" value=\"submit$id\" src=\"addtocart.jpg\" width=\"144\" height=\"34\" border=\"0\" alt=\"Add to Cart\" name=\"image$id\">
    </div>";
    } else {
    $clicker = "
    <table>
    <tr><td align=\"right\">
    Material:
    </td><td>
    <select name=\"material$id\" style=\"background-color: #FFFFFF; border: solid 1px #000000; height: 20px; font-size: 10px;\">
    <option value=\"Stainless\">Stainless Steel</option>
    <option value=\"Mild\">Mild Steel</option>
    </select>
    </td></tr>
    <tr><td align=\"right\">
    Finish:
    </td><td>
    <select name=\"finish$id\" style=\"background-color: #FFFFFF; border: solid 1px #000000; height: 20px; font-size: 10px;\">
    <option value=\"Uncoated\">Uncoated</option>
    <option value=\"Black\">Black</option>
    <option value=\"Other\">Other</option>
    </select><br />
    </td></tr>
    </table>
    <div class=\"product_image\">
    <input type=\"image\" value=\"submit$id\" src=\"addtocart.jpg\" width=\"144\" height=\"34\" border=\"0\" alt=\"Add to Cart\" name=\"image$id\">
    </div>";
    }
    
    if( $odd = $checknum%2 ) {
    	$content .= "
    	<form action=\"index.php?page=product_page&product_cat=$product_cat\" method=\"post\" name=\"add_product$id\">
    	<div class=\"product_left\">
    	<div class=\"product_image\"><img src=\"products/$partnumber&#45;cart.jpg\" class=\"jkimagelarge\" title=\"products/$partnumber.jpg\" height=\"100\"/></div>
    	<div class=\"product_info\">
    	$partname
    	<br />
    	$partnumber
    	<br />
    	$$price
    	<br /><br />
    
    $clicker</div></div>
    </form>";
    } else {
    	$content .= "
    	<div class=\"product_right\">
    	<form action=\"index.php?page=product_page&product_cat=$product_cat\" method=\"post\" name=\"add_product$id\">
    	<div class=\"product_image\"><img src=\"products/$partnumber&#45;cart.jpg\" class=\"jkimagelarge\" title=\"products/$partnumber.jpg\" height=\"100\"/></div>
    	<div class=\"product_info\">
    	$partname
    	<br />
    	$partnumber
    	<br />
    	$$price
    	<br /><br />
    $clicker</div></div>
    			<div class=\"productspace\"></div>
    
    </form>";	}
    
    
    $checknum ++;
    }
    
    
    
    
    ?>
    

     

    With the echo "$_POST" I get this displayed:

     

    Array

    (

        [material11] => Stainless

        [finish11] => Uncoated

        [size11] =>

        [hideme] => needsize

        [image11_x] => 36

        [image11_y] => 16

    )

    1

     

    Then the page is just sitting there as if it hadn't changed a bit.

  3. I have a product page that generates boxes for each item, which fill the screen going vertically. 2 columns of boxes. Firefox it works without a problem, in IE when it runs off the screen, the scroll bar is gone and where the screen ends it just cuts the content there. I've never had this problem before!  ???

     

    product page:

    <?php
    header("Cache-control: private");
    if(!isset($_SESSION["id"]))
    {
    header("Location: index.php?page=login");
    exit;
    }
    
    
    $product_cat = $_GET['product_cat'];
    $checknum = 1;
    $result = mysql_query("SELECT * FROM `p_products` WHERE category='$product_cat'") or DIE(mysql_error());
    while($r = mysql_fetch_array($result))
    {
      $id = $r['id'];
      $partnumber = $r['partnumber'];
      $partname = $r['partname'];
      $description = $r['description'];
      $price = $r['price'];
      $option1 = $r['option1'];
    $specialid = $id;
    
    $postname = image.$id;
    $postsize = size.$id;
    
    if (isset($_POST[$postname])) {
    $error = 0;
    if (isset($_POST['hideme'])) {
    if (empty($_POST[$postsize])){
    $error = 1;
    $errormsg = "You must fill in a Pipe Size for $partname.";
    } else {
    $sizenum = $_POST[$postsize];
    $specialid = $id.";".$sizenum;
    }
    
    
    
    
    
    }
    
    
    if ($error == 1){
    $errordisplay .= "<div id=\"error_box\">   $errormsg</div>";
    } else {
    
    
    
    $materialid = material.$id;
    $material = $_POST[$materialid];
    
    
    
    if (isset($_SESSION['cart'][$id][$material])) {
    
    
    
    
      foreach ($_SESSION['cart'] as $id2 => $array2){
    
    		if ($id2 == $id) {
    
    		foreach ($array2 as $material2 => $array3){
    
    		if ($material2 == $material) {
    
    $newqty = $array3['qty'];
    $newqty ++;
    $_SESSION['cart'][$id][$material] = array(qty => $newqty, size => 7.3);
    header("Location: index.php?page=cart");
    exit;
    
    	   }
    
      }
               }
    
    
    
    
    
    
    
        	}
    
    
    
    
    
    
    } else {
    
    $_SESSION['cart'][$id][$material] = array(qty => 1, size => 7.3);
    
    header("Location: index.php?page=cart");
    exit;
    }
    }
    
    
    
    }
    
    
    if (!empty($option1)){
    $clicker = "
    Material:
    <select name=\"material$id\" style=\"background-color: #FFFFFF; border: solid 1px #000000; height: 20px; font-size: 10px;\">
    <option value=\"Stainless\">Stainless Steel</option>
    <option value=\"Mild\">Mild Steel</option>
    </select><br />
    Pipe Size: <input type=\"text\" size=\"4\" value=\"\" name=\"size$id\" style=\"background-color: #FFFFFF; border: solid 1px #000000; height: 20px; font-size: 10px;\" /><br />
    <div class=\"product_image\">
    <input type=\"hidden\" name=\"hideme\" value=\"needsize\" />
    <input type=\"image\" value=\"submit$id\" src=\"addtocart.jpg\" width=\"144\" height=\"34\" border=\"0\" alt=\"Add to Cart\" name=\"image$id\">
    </div>";
    } else {
    $clicker = "
    Material:
    <select name=\"material$id\" style=\"background-color: #FFFFFF; border: solid 1px #000000; height: 20px; font-size: 10px;\">
    <option value=\"Stainless\">Stainless Steel</option>
    <option value=\"Mild\">Mild Steel</option>
    </select><br /><div class=\"product_image\">
    <input type=\"image\" value=\"submit$id\" src=\"addtocart.jpg\" width=\"144\" height=\"34\" border=\"0\" alt=\"Add to Cart\" name=\"image$id\">
    </div>";
    }
    
    if( $odd = $checknum%2 ) {
    	$content .= "
    	<form action=\"index.php?page=product_page&product_cat=$product_cat\" method=\"post\" name=\"add_product$id\">
    	<div class=\"product_left\">
    	<div class=\"product_image\"><img src=\"products/$partnumber&#45;cart.jpg\" class=\"jkimagelarge\" title=\"products/$partnumber.jpg\" height=\"100\"/></div>
    	<div class=\"product_info\">
    	$partname
    	<br />
    	$partnumber
    	<br />
    	$$price
    	<br />
    
    $clicker</div></div>
    </form>";
    } else {
    	$content .= "
    	<div class=\"product_right\">
    	<form action=\"index.php?page=product_page&product_cat=$product_cat\" method=\"post\" name=\"add_product$id\">
    	<div class=\"product_image\"><img src=\"products/$partnumber&#45;cart.jpg\" class=\"jkimagelarge\" title=\"products/$partnumber.jpg\" height=\"100\"/></div>
    	<div class=\"product_info\">
    	$partname
    	<br />
    	$partnumber
    	<br />
    	$$price
    	<br />
    $clicker</div></div>
    			<div class=\"productspace\"></div>
    
    </form>";	}
    
    
    $checknum ++;
    }
    
    
    
    
    ?>
    
    
    
    

     

     

     

    stylesheet

    html,body{height:100%}
    html,body{margin:0;padding:0}
    body {
        text-align:center;
        background-image: url(bg.jpg);
        font: 0.8125em Verdana, sans-serif;
        color: #000;
    }
    #container {
        margin-left: auto;
        margin-right: auto;
        text-align: left;
        width: 1030px;
    background: url(insidebg.jpg) repeat-y left top;
        min-height:100%;
        overflow: hidden;
    }
    * html #container{height:100%}
    
    
    #container_left {
    float: left;
    width: 260px;
    text-align: left;
    background-image: url(menubg.jpg);
    }
    
    #container_right {
    float: left;
    width: 710px;
    text-align: center;
    position: relative;
    display: inline;
    background-color: #000;
    }
    
    #container_far_right {
    float: right;
    width: 60px;
    }
    
    
    
    
    
    #overlappopup{ /*don't change id name */
    position: absolute; /*don't change position property */
    z-index: 1000;
    background: white;
    border: 2px solid black;
    padding: 0px;
    left: 0;
    top: 0;
    visibility: hidden;
    }
    
    
    
    
    
    
    
    
    
    #user_box {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    height: 50px; width: 660px;
    background-color: #1E1E1E;
    color: #FFFFFF;
    }
    
    #outsidelogin {
    float:left;
    line-height: 50px;
    height: 50px;
    width: 400px;
    color: #FFFFFF;
    }
    
    #loginbox {
    width: 260px;
    height: 50px; 
    float:right;
    font-size: 9px;
    }
    
    #featured_product {
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    background-color: #FFFFFF;
    height: 254px; width: 631px;
    }
    
    #cat_box {
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    height: 40px; width: 631px;
    background-color: #1E1E1E;
    color: #FFFFFF;
    font-size: 1em;
    line-height: 40px;
    }
    
    #error_box {
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    height: 40px; width: 625px;
    background-color: #1E1E1E;
    color: #FFFFFF;
    border: 3px solid red;
    font-size: 1em;
    line-height: 40px;
    }
    
    #product_container {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    width: 631px;
    }
    
    .productspace {
    float: right;
    width: 631px; height: 1px;
    }
    
    .producttop {
    text-align: left;
    width: 293px; height: 3px;
    background-image: url(boxtop.jpg);
    }
    
    .product_left {
    text-align: left;
    float: left;
    width: 293px;
    background-color: #FFF;
    margin-bottom: 15px;
    }
    
    .product_info {
    padding: 10px;
    }
    
    .product_right {
    text-align: left;
    float: right;
    width: 293px;
    background-color: #FFF;
    margin-bottom: 15px;
    }
    
    .product_image {
    padding: 5px;
    text-align: center;
    }
    
    .black_menu {
    background-color: #000000;
    color: #FFFFFF;
    width: 145px; height: 20px;
    line-height: 20px;
    font-size: .85em;
    margin-bottom: 5px;
    margin-left: 100px;
    }
    
    
    .cat_menu_title {
    color: #FFFFFF;
    width: 150px; height: 20px;
    line-height: 20px;
    font-size: .85em;
    margin-bottom: 5px;
    margin-top: 20px;
    margin-left: 95px;
    }
    
    .cat_menu {
    color: #FFFFFF;
    width: 150px; 
    font-size: .85em;
    margin-bottom: 2px;
    margin-left: 110px;
    }
    
    
    .spacer { height: 30px; }
    
    a:link, a:visited {
    color: #FFFFFF;
    text-decoration: none;
    }
    a:hover, a:visited:hover {
    color: #F2F2F2;
    text-decoration: underline;
    }
    
    h1 {
    font-family: verdana;
    color: #A51111;
    font-size: 15pt;
    }
    
    #full_content {
    text-align: left;
    width: 601px;
    background-color: #FFFFFF;
    padding: 15px;
    }
    
    #full_content a {
    color: #000;
    }
    
    .registration_form {
    font-size: 12px;
    padding: 0px;
    spacing: 0px;
    }
    .login_form {
    font-size: 9px;
    padding: 0px;
    spacing: 0px;
    color: #FFFFFF;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    

     

    Also, while I'm posting this.. the 'add to cart' button on the right column creates an awkward space just below the item. If you'd like to see this in action: http://www.berryequipment.net/performance/ and signup, doesn't take too long, though you will get an email confirmation. (not required, but if you'd like to see it doing it) Then when logged in click on one of the categories.

  4. Would it be:

    $postqty = $id2.$material2;

    echo "$$_POST[$postqty]";

    or

    $postqty = $id2.$material2;

    echo "$_POST[$$postqty]";

     

    The first one doesn't echo anything and the second one produces a white page.

     

     

     

    edit: the actual post should be  $_POST['4mild'] or $_POST['8stainless'] something like that, which I'm needing to do a certain task whenever I get to the spot in my loop where idmaterial is = the piece inside that post bracket. Hope this makes sense.

  5. Q2: They aren't stored in your database, which is why you are doing a session. They are stored in that session as an array.

     

    Q3: If they close the window (and I may be wrong on this, but I'm fairly sure) the session will time out after a set period of time, set by the server or by you when creating the session.

    Q3-B: I believe you can set the session to time out at whatever amount of time you wish.

     

    Q4: So that they don't lose their information by a session timeout, you would need cookies.

  6. Don't know how to topic this, but I have an input like this:

    <input type=\"text\" name=\"$id$material\" value=\"{$array3['qty']}\" size=\"3\" maxlength=\"3\" />

     

    Maybe I should say, several inputs. They each have a unique name as you can see. No two will be the same with this method. Now while I'm running another script after this has been submitted, I'm needing to do something if the name of this input field matches the id/material that I am currently at in my loop. So I need to compare the name before I grab the value. I have no problem grabbing the value of my inputs with a $_POST[$id$material] type of thing.

  7. Return ends the script, which causes everything that should be displayed after that function to not exist.. So I am thinking this isn't what I'm looking for? Here is what I have:

     

     

    function in my functions.php

    
    function showCart() {
    global $db;
    
    
    
    
    
    
    if (isset($_SESSION['cart'])) {
    
          	  print '<form action="index.php?page=cart&action=update" method="post" id="cart">';
    
      foreach ($_SESSION['cart'] as $id => $array2){
      foreach ($array2 as $material => $array3){
    
    $result = mysql_query("SELECT * FROM p_products WHERE id='$id'") or DIE(mysql_error());
    
    	while($r=mysql_fetch_array($result))
    	{
    
    	$partnumber=$r["partnumber"];
    	$partname=$r["partname"];
    	$description=$r["description"];
    	$category=$r["category"];
    	$price=$r["price"];
    
    	}
    
    
    
    
    return "
    <table width=\"590\" style=\"border-top: 1px solid #000;\">
    <tr>
    <td width=\"100\"><img src=\"products/$partnumber-cart.jpg\" class=\"jkimagelarge\" title=\"products/$partnumber.jpg\" /></td>
    <td width=\"350\">
    $partname<br />
    $partnumber<br />
    $price / each<br />
    Material: $material
    </td>
    <td width=\"60\"><input type=\"text\" name=\"qty$id\" value=\"{$array3['qty']}\" size=\"3\" maxlength=\"3\" /></td>
    <td width=\"80\">$($price * {$array3['qty']})</td>
    </tr>
    
    
    
    
    
    </table>
    
    ";
    
    
        }
    }
    
    
         	 print '</form>';
    } else {
         	 print '<p>You shopping cart is empty.</p>';
    }
    
    
    }
    
    

     

     

     

    my cart.php

    
    $showCart = showCart(0);
    
    $content .= "<div id=\"full_content\">
    
    Shopping Cart<br />
    
    $showCart
    
    </div>";
    
    
    

  8. My function for showCart:

    function showCart() {
    global $db;
    
    echo "<pre><div style=\"text-align: left;\">";
    print_r ($_SESSION['cart']);
    echo "</div></pre>";
    
    
    
    
    if (isset($_SESSION['cart'])) {
    
          	  print '<form action="index.php?page=cart&action=update" method="post" id="cart">';
    
      foreach ($_SESSION['cart'] as $id => $array2){
      foreach ($array2 as $material => $array3){
    
    $result = mysql_query("SELECT * FROM p_products WHERE id='$id'") or DIE(mysql_error());
    
    	while($r=mysql_fetch_array($result))
    	{
    
    	$partnumber=$r["partnumber"];
    	$partname=$r["partname"];
    	$description=$r["description"];
    	$category=$r["category"];
    	$price=$r["price"];
    
    	}
    
    
    
    
    echo "
    <table width=\"590\" style=\"border-top: 1px solid #000;\">
    <tr>
    <td width=\"100\"><img src=\"products/$partnumber-cart.jpg\" class=\"jkimagelarge\" title=\"products/$partnumber.jpg\" /></td>
    <td width=\"350\">
    $partname<br />
    $partnumber<br />
    $price / each<br />
    Material: $material
    </td>
    <td width=\"60\"><input type=\"text\" name=\"qty$id\" value=\"{$array3['qty']}\" size=\"3\" maxlength=\"3\" /></td>
    <td width=\"80\">$($price * {$array3['qty']})</td>
    </tr>
    
    
    
    
    
    </table>
    
    ";
    
    
        }
    }
    
    
         	 print '</form>';
    } else {
         	 print '<p>You shopping cart is empty.</p>';
    }
    
    
    }
    

     

    As you can see right now I am using echo/print to get the info out, but that's putting the information above all of my content of my website, when I want it to go under "Shopping Cart" where I have the variable $showcart at..

  9. Now,

    foreach ($_SESSION['cart'] as $id => $array2){
      foreach ($array2 as $material => $array3){
          echo "$id $material ";
    
      foreach ($array3 as $key => $key2){
    
    if ($key == qty) {
    echo "QUANTITY: $key2";
    } else {
    echo " $key: $key2";
    }
    
        }
    echo "<br />";
    
    }
    }
    

     

    Results:

    8 mildsteel QUANTITY: 1 size: 4.5

    8 stainless QUANTITY: 1 size: 4.5

     

    Though I think I should still have some sort of more control over it than I am having right now? I know SOMEONE has a solution to this!

     

     

     

    edit: changed the inside foreach,

      foreach ($_SESSION['cart'] as $id => $array2){
      foreach ($array2 as $material => $array3){
          echo "$id $material ";
    
      foreach ($array3 as $key => $key2){
    
    if ($key == qty) {
    $qty = $key2;
    }
    if ($key == size) {
    $size = $key2;
    }
    
        }
    echo "$size $qty<br />";
    
    }
    }
    

     

    So that gives me a slight bit more flexibility but I am almost sure there has got to be a way to do this without using the if statements?

  10. Sigh, now I'm to this:

      foreach ($_SESSION['cart'] as $id => $array2){
      foreach ($array2 as $material => $array3){
          echo "$id $material ";
    
      foreach ($array3 as $key => $key2){
    
    echo " $key2";
    
        }
    echo "<br />";
    
    }
    }
    

     

    which displays

     

    8 mildsteel 1 4.5

    8 stainless 1 4.5

     

    but I obviously still can't control my quantity and size in to their own variables.. just a general $key2, not sure how to break it down better.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.