Jump to content

smileyrva

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

smileyrva's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Can anyone please help? I just need a simple dropdown box with 4 choices (IE: Small, Med, Large, XL) that can be defined as a variable to be added in a DB. It seems easy but it is kicking my butt. It is the ww.phpwebcommerce.com cart if it makes it easier. Any help would be greatly appreciated, thank you!
  2. im still getting an undefined variable error. if it makes it easier this is the phpwebcommerce cart (plaincart?).
  3. So if my form is method=post how can i define that on the next page?
  4. I just tried to see if I could echo the query...I tried displaying the size in cart.php and im getting an undefined variable error.
  5. That was the functions that are called upon after you add to cart but maybe the problem lies in my productdetail.php? would give the answer. I still cannot figure this out and its driving me crazzzzyyyyy. lol. if anyone can help I would really appreciate it, thanks! <?php if (!defined('WEB_ROOT')) { exit; } $product = getProductDetail($pdId, $catId); // we have $pd_name, $pd_price, $pd_description, $pd_image, $cart_url extract($product); ?> <table width="100%" border="0" cellspacing="0" cellpadding="10"> <tr> <td align="center"><img src="<?php echo $pd_image; ?>" border="0" alt="<?php echo $pd_name; ?>"></td> <td valign="middle"> <strong><?php echo $pd_name; ?></strong><br> Price : <?php echo displayAmount($pd_price); ?><br> <?php // if we still have this product in stock // show the 'Add to cart' button if ($pd_qty > 0) { ?> <br> <br> Size: <select size="1" name="size"> <option value="Small">Small</option> <option>Medium</option> <option>Large</option> <option>Extra Large</option> </select> <br> <input type="button" name="btnAddToCart" value="Add To Cart >" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton"> <?php } else { echo 'Out Of Stock'; } ?> </td> </tr> <tr align="left"> <td colspan="2"><?php echo $pd_description; ?></td> </tr> </table>
  6. // does the product exist ? $sql = "SELECT pd_id, pd_qty FROM tbl_product WHERE pd_id = $productId"; $result = dbQuery($sql); if (dbNumRows($result) != 1) { // the product doesn't exist header('Location: cart.php'); } else { // how many of this product we // have in stock $row = dbFetchAssoc($result); $currentStock = $row['pd_qty']; if ($currentStock == 0) { // we no longer have this product in stock // show the error message setError('The product you requested is no longer in stock'); header('Location: cart.php'); exit; } } // current session id $sid = session_id(); session_register("size"); $size = $_SESSION['size']; // check if the product is already // in cart table for this session $sql = "SELECT pd_id FROM tbl_cart WHERE pd_id = $productId AND ct_session_id = '$sid'"; $result = dbQuery($sql); if (dbNumRows($result) == 0) { // put the product in cart table $sql = "INSERT INTO tbl_cart (pd_id, ct_qty, size, ct_session_id, ct_date) " . "VALUES ($productId, 1, '$size', '$sid', NOW())"; $result = dbQuery($sql); } else { // update product quantity in cart table $sql = "UPDATE tbl_cart SET ct_qty = ct_qty + 1 WHERE ct_session_id = '$sid' AND pd_id = $productId"; $result = dbQuery($sql); } This is just a piece of my cartfunctions.php (which is an include() once you add an item to the cart). I've been trouble shooting this all day and finally got it to stop giving me error messages. Im trying to allow the user to pick a size between 4 options, after that it is added to the cart and I can easily find out what size shirt the customer wants before I ship it. but now it wont update the $size variable to the DB. Am I defining this wrong or maybe my whole approach is messed up? If you would like to see the setup you can go to rbcrime.com/newshop/newshop/ .
  7. Its working now. I didnt need to encrypt the password in the first place so I got rid of that. I was not familiar with the PASSWORD() function and got confused with it. Thanks for your help.
  8. So if I were to just take out the PASSWORD() tags and change the settings in my DB it should work? Im going to give it a shot with $sql = "SELECT user_id FROM tbl_user WHERE user_name = '$userName' AND user_password = '$password'";
  9. Just gave it a shot. The MySQL query worked, but the password was just generated into another group of random numbers. I tried running the script with password "test." also didnt work.
  10. The password does get stored as a bunch of numbers. Does this mean thats my new password? Ive tried using that string of numbers to login and that doesnt work either. Is there a possible way around it without using the PASSWORD() query?
  11. I actually think what is happening is its not setting a session variable. It checks for a session ID but for some reason its not being set... here is my checkuser function. function checkUser(){ if (!isset($_SESSION['plaincart_user_id'])) { header('Location: ' . WEB_ROOT . 'admin/login.php'); } if (isset($_GET['logout'])) { doLogout(); }}
  12. Its been quite a while since ive done anything PHP related but I decided to help a buddy with a website so he can sell his clothing company products online. I found a simple, pre made shopping cart script that seems to run fine. EXCEPT...the admin login. For some reason I keep getting returned to the same page, with the same error(pass and user didnt match). I know for sure that they do, therefore I am absolutely stumped. I have compared this code with books I have and cant seem to fix it. Can anyone help?? function doLogin() { // if we found an error save the error message in this variable $errorMessage = ''; $userName = $_POST['txtUserName']; $password = $_POST['txtPassword']; // first, make sure the username & password are not empty if ($userName == '') { $errorMessage = 'You must enter your username'; } else if ($password == '') { $errorMessage = 'You must enter the password'; } else { // check the database and see if the username and // password combo do match $sql = "SELECT user_id FROM tbl_user WHERE user_name = '$userName' AND user_password = PASSWORD('$password')"; $result = dbQuery($sql); if (dbNumRows($result) == 1) { $row = dbFetchAssoc($result); $_SESSION['plaincart_user_id'] = $row['user_id']; // log the time when the user last login $sql = "UPDATE tbl_user SET user_last_login = NOW() WHERE user_id = '{$row['user_id']}'"; dbQuery($sql); // now that the user is verified we move on to the next page // if the user had been in the admin pages before we move to // the last page visited if (isset($_SESSION['login_return_url'])) { header('Location: ' . $_SESSION['login_return_url']); exit; } else { header('Location: index.php'); exit; } } else { $errorMessage = 'Wrong username or password'; } } return $errorMessage; }
×
×
  • 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.