Jump to content

smallc28

Members
  • Posts

    38
  • Joined

  • Last visited

Posts posted by smallc28

  1. Where can I learn more about this I'm good at programming things but not so great at security. This is just practice for me that's why it lack security but Thanks 

  2. Hello PHP freak members I learn how to ecrypt my password using the blow fish method but I'm having trouble decypting the password. Is there anyone that can over see the problem that I'm having? 

     

    Sample ecrypted password > $2y$09$Q5klufp7bj6iuBA3dHpz5.fLN1sLzeGKE7nuXKunLMKKvE.rZtSTW

    Original password > 1234 

     



    <?php 
    error_reporting(E_ALL & ~E_NOTICE);
    session_start();
    if(isset ($_SESSION['id'])){
    header('location: profile.php');
    } else {
    if($_POST['submit']){
    include "connect_prompt/connect_query.php";
     $email = mysqli_real_escape_string($db_conx,$_POST['email']); 
     $password_one =  $_POST['password_one']; 


    ///////////////// Blow Fish ///////////////////////////////////


     function cryptPass($input, $rounds = 9){
    $salt = "";
    $saltChars = array_merge(range('A','Z'),range('a','z'),range(0,9));
    for($i = 0; $i < 22; $i++){
    $salt .= $saltChars[array_rand($saltChars)];
    }
    return crypt($input, sprintf('$2y$%02d$', $rounds) . $salt);
    }
    $password_one = $_POST['password_one'];
    $password = $_POST['password'];
    $hashedPass = cryptPass($password);


    if(crypt($password_one, $hashedPass) == $hashedPass){




    ///////////////// Blow Fish ///////////////////////////////////


    $sql = "SELECT id, email, password FROM customer WHERE email='$email' AND password='$password_one' LIMIT 1";
    $query = mysqli_query ($db_conx, $sql);
    if($query){
    $row = mysqli_fetch_row($query);
    $userID = $row[0];
    $db_email = $row[1];
    $db_password = $row[2];
    }
    if($email == $db_email && $password_one == $db_password){
    $_SESSION['email'] = $email;
    $_SESSION['id'] = $userID;
    header("location: profile.php");
    } else {
    echo "Sorry, Username or Password was incorrect";
    }
    }
      }
    }
    ?>




    <form 
    action="login.php" method="POST">
        <input type="email" name="email" id="email" placeholder="  your@email.com" />
        <br/><br/>
        <input type="password" name="password_one" id="password_one" placeholder="  ********" />
        <br/><br/>
        <input type="submit" name="submit" value="SIGN IN" />
    </form>

  3. Difficultly level to creating this is very easy

    but time consuming as well

     

    first you want to create the database table of everything you need

     

    then html

     

    after php

     

    your way through  

     

    I'll help you but doubt I build it for you  :tease-01:

  4. Hello There  :)

     

    I've created an Voucher In MySQL/Database system. I would like to know how would I go about programming it into my shopping cart so when a client has an secret Voucher / Coupon they can have a percentage off of the total price of the items their trying to purchase then place thats final price into paypal checkout. shopping cart and database of the Voucher shown below thanks in advance.

     

    <?php 
    require "connect_query.php";
     
    $voucher = "CREATE TABLE `voucher_code` (
    `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
    `vouchercode` VARCHAR( 16 ) NOT NULL ,
    `active` TINYINT( 1 ) NOT NULL ,
    `min_basket_cost` FLOAT NOT NULL ,
    `voucher_operation` ENUM( '-', '%', 's' ) NOT NULL ,
    `voucher_amount` FLOAT NOT NULL ,
    `num_vouchers` INT( 11 ) NOT NULL DEFAULT '-1',
    `expiry` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
    PRIMARY KEY ( `ID` )";
    if (mysqli_query($db_conx,$voucher)){
    echo "Vouchar Table has been CREATED :)";
    }else{
    echo "Vouchar TABLE was not a success :(";
    }
    ?>
     

     

    ////////////////////////////////////// Cart.php

    <?php
    // Start session first thing in script 
    session_start(); 
    // Script Error Reporting
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    // Connect to the MySQL database  
     include "connect_prompt/connect_query.php";  
    ?>
    <?php 
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 1 (if user attempts to add something to the cart from the product page)
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($_POST['pid'])) {
        $pid = $_POST['pid'];
    $size = $_POST['size'];
    $wasFound = false;
    $i = 0;
     
    // If the cart session variable is not set or cart array is empty
    if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { 
       // RUN IF THE CART IS EMPTY OR NOT SET
    $_SESSION["cart_array"] = array(1 => array("item_id" => $pid, "size" => $size, "quantity" => 1));
           } else {
    // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT
    foreach ($_SESSION["cart_array"] as $each_item) { 
         $i++;
         while (list($key, $value) = each($each_item)) {   
        if ($key == "item_id" && $value == $pid){
        if ($each_item['size'] == $size){
            // That item is in cart already so let's adjust its quantity using array_splice()
    array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "size" => $size, "quantity" => $each_item['quantity'] + 1)));
     $wasFound = true;
     }} // close if condition
         } // close while loop
          } // close foreach loop
      if ($wasFound == false) {
      array_push($_SESSION["cart_array"], array("item_id" => $pid,"size" => $size, "quantity" => 1));
      }
    }
    header("location: cart.php"); 
        exit();
    }
     
    ?>
     
    <?php
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 2 (if user chooses to empty their shopping cart)
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($_GET['cmd']) && $_GET['cmd'] == "emptycart") {
        unset($_SESSION["cart_array"]);
    }
    ?>
    <?php 
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 3 (if user chooses to adjust item quantity)
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($_POST['item_to_adjust']) && $_POST['item_to_adjust'] != "") {
        // execute some code
    $item_to_adjust = $_POST['item_to_adjust'];
    $size = $_POST['size'];
     
    $quantity = $_POST['quantity'];
    $quantity = preg_replace('#[^0-9]#i', '', $quantity); // filter everything but numbers
    if ($quantity >= 100) { $quantity = 99; }
    if ($quantity < 1) { $quantity = 1; }
    if ($quantity == "") { $quantity = 1; }
    $i = 0;
    foreach ($_SESSION["cart_array"] as $each_item) { 
         $i++;
         while (list($key, $value) = each($each_item)) {
     if ($key == "item_id" && $value == $item_to_adjust) {
     if ($each_item['size'] == $size ){
     // That item is in cart already so let's adjust its quantity using array_splice()
     array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $item_to_adjust, "quantity" => $quantity, "size" => $size)));
     } // close if condition
         } // close while loop
    } // close foreach loop
    }
    }
    ?>
     
    <?php 
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 4 (if user wants to remove an item from cart)
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != "") {
        // Access the array and run code to remove that array index
      $key_to_remove = $_POST['index_to_remove'];
    if (count($_SESSION["cart_array"]) <= 1) {
    unset($_SESSION["cart_array"]);
    } else {
    unset($_SESSION["cart_array"]["$key_to_remove"]);
    sort($_SESSION["cart_array"]);
    }
    }
    ?>
    <?php 
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //       Section 5  (render the cart for the user to view on the page)
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $cartOutput = "";
    $cartTotal = "";
    $pp_checkout_btn = '';
    $product_id_array = '';
    if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
        $cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>";
    } else {
    // Start PayPal Checkout Button
    $pp_checkout_btn .= '<form action="[url=https://www.paypal.com/cgi-bin/webscr]https://www.paypal.com/cgi-bin/webscr[/url]" method="post">
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="upload" value="1">
        <input type="hidden" name="business" value="myemail@gmail.com">';
    // Start the For Each loop
    $i = 0; 
        foreach ($_SESSION["cart_array"] as $each_item) { 
    $item_id = $each_item['item_id']; 
    $sql = "SELECT * FROM products WHERE id='$item_id' LIMIT 1";
    $query = mysqli_query ($db_conx,$sql);
    while ($row = mysqli_fetch_array($query)){
    $product_name = $row["product_name"];
    $price = $row["price"];
    $details = $row["details"];
    $taxes = $row["taxes"];
    $shipping_one =$row['shipping_one'];
    }
     
    $pricetotal = $price  * $each_item['quantity'];
    $cartTotal = $pricetotal  + $shipping_one + $taxes + $cartTotal;
     
    setlocale(LC_MONETARY, "en_US");
            //$pricetotal = money_format("%10.2n", $pricetotal);
    // Dynamic Checkout Btn Assembly
    $x = $i + 1;
    $pp_checkout_btn .= '
    <input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '">
            <input type="hidden" name="amount_' . $x . '" value="' . $price . '">
            <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '">
            <input type="hidden" name="handling_'. $x . '"value="'. $shipping_one .'"> 
            <input type="hidden" name="tax_'. $x . '"value="'. $taxes .'"> 
       <input type="hidden" name="on0_' . $x . '" value="' . $each_item['size'] . '">'; 
    // Create the product array variable
    $product_id_array .= "$item_id-".$each_item['quantity'].","; 
    // Dynamic table row assembly
    $cartOutput .= "<tr>";
    $cartOutput .='<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>';
     
     
            $cartOutput .= '<td>' . $each_item['size'] .'</td>';
            $cartOutput .= '<td>' . $details . '</td>';
    $cartOutput .= '<td>$' . $price . '</td>';
    $cartOutput .= '<td><form action="cart.php" method="post">
    <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" />
    <input name="adjustBtn' . $item_id . '" type="submit" value="change" />
    <input name="item_to_adjust" type="hidden" value="' . $item_id . '" />
    </form></td>';
    //$cartOutput .= '<td>' . $each_item['quantity'] . '</td>';
    $cartOutput .= '<td>' . $pricetotal . '</td>';
    $cartOutput .= '<td><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>';
    $cartOutput .= '</tr>';
    $i++; 
        } 
    setlocale(LC_MONETARY, "en_US");
       // $cartTotal = money_format("%10.2n", $cartTotal);
    $cartTotal = "<div style='font-size:18px; margin-top:12px;' align='right'>Cart Total : ".$cartTotal." USD</div>";
        // Finish the Paypal Checkout Btn
    $pp_checkout_btn .= '<input type="hidden" name="custom" value="' . $product_id_array . '">
    <input type="hidden" name="notify_url" value="[url=https://www.shopstorms.com/storescripts/my_ipn.php]https://www.shopstorms.com/storescripts/my_ipn.php">[/url]
    <input type="hidden" name="return" value="[url=https://www.mywebsite.com/checkout_complete.php]https://www.mywebsite.com/checkout_complete.php">[/url]
    <input type="hidden" name="rm" value="2">
    <input type="hidden" name="cbt" value="Return to The Store">
    <input type="hidden" name="cancel_return" value="[url=https://www.mywebsite.com/paypal_cancel.php]https://www.mywebsite.com/paypal_cancel.php">[/url]
    <input type="hidden" name="lc" value="US">
    <input type="hidden" name="currency_code" value="USD">
    <input type="image" src="[url=http://www.paypal.com/en_US/i/btn/x-click-but01.gif]http://www.paypal.com/en_US/i/btn/x-click-but01.gif[/url]" name="submit" alt="Make payments with PayPal - its fast, free and secure!">
    </form>';
    }
    ?>
     
    <?php 
    if(!empty($pricetotal)) { ?>
    <?php
            $discount ="";
     
    if($pricetotal >= 50){
    echo "FREE SHIPPING!";
    }
    elseif ($pricetotal <= 50){
    echo "SPEND MORE THAN 50 GET FREE SHIPPING!";
    }
     
    ?>
    <?php } ?>
    <body>
    <div align="center" id="mainWrapper">
      <div id="pageContent">
        <div style="margin:24px; text-align:left;">
     
        <br />
        <table width="1024" border="1" cellspacing="0" cellpadding="6" align="center" style="background-color:white;">
          <tr>
            <td width="18%" bgcolor="#C5DFFA"><strong>Product</strong></td>
            <td align="center" width="10%" bgcolor="#C5DFFA"><strong>Size</strong></td>
            <td width="45%" bgcolor="#C5DFFA"><strong>Product Description</strong></td>
            <td width="10%" bgcolor="#C5DFFA"><strong>Unit Price</strong></td>
            <td width="9%" bgcolor="#C5DFFA"><strong>Quantity</strong></td>
            <td width="9%" bgcolor="#C5DFFA"><strong>Total</strong></td>
            <td width="9%" bgcolor="#C5DFFA"><strong>Remove</strong></td>
          </tr>
         <?php echo $cartOutput; ?>
         <!-- <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
          </tr> -->
        </table>
        <table width="1024" border="0" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <th scope="col" align="left"><a href ="cart.php?cmd=emptycart">Click Here to Empty Your Shopping Cart</a></th>
        <th scope="col" align="center" style="color:black;">
        <?php if(!empty ($taxes)) { ?>
         <?php echo $taxes; ?>
             <?php } ?>
       <br/>
        <?php if(!empty ($shipping_one)) { ?> 
         <?php echo $shipping_one; ?>
             <?php } ?>
       <br/>
        <?php if(!empty ($cartTotal)) { ?> 
         <?php echo $cartTotal; ?>
             <?php } ?>
        <br/><?php if(!empty ($discount)) { ?>
             <?php echo $discount; ?>
                 <?php } ?>
        <br/> 
        </th>
      </tr>
    </table>
        <table width="1024" height="50" border="0" cellspacing="10" cellpadding="0" align="center">
      <tr>
        <th width="913" align="left" scope="col"></th>
        <th width="105" align="right" scope="col"><?php echo $pp_checkout_btn; ?> </th>
      </tr>
    </table>
        <br />
    <br />
     
        <br />
        <br />
        
        </div>
       <br />
      </div>
    </div>
    </body>
    </html>
  5. I've never done this before but I'm trying my best to master shopping carts 

     

    But I'm trying to go for both so I can cover my ass incase a client wants both.

     

    May I add you as a friend for future help on this project? I'm going to give this a go hopefully I do it the right way lol.

  6. Hello this may sound a little confusing.

     

    I recently made a fake website with a quantity stock what I mean by this is

    let's I have 1 pair of jeans but I have the quantity or stock of 10 of the same pair of jeans.

     

    Okay now when the customer goes to select this item and buy and (*they make up their mind whether to buy it or not*) <!-- shopper joke 

     

    Anyways they buy themselves a pair or 2 or 3 or 4 or 10! I'd like to know how would I be able to set the quantity to subject itself from the shopping cart when each customer makes a purchase and lock as soon as the last pair of jeans are sold.

     

    2 Image below just incase someone gets confused. 

     

    Thanks a mill!  :pirate:

     

     

     

     

     

    post-133640-0-71380400-1391912465_thumb.jpg

    post-133640-0-41995400-1391912473_thumb.jpg

  7. Hello 
    I've created an recently viewed Items list it works but I'm having two(2) problems.
    1. session repeats the same Id
    2. session goes on and on and on.....

    My questions are:
    1. how would I set it so that it doesn't repeat the same session/Id again?
    2. how may I set the maximum limit to  5?

     

    I've attach an Image file of what I'm trying to say anyone doesn't understand.

    <?php 
    session_start();
    ?>

    <?php
    $_SESSION['recentlyViewed'] .='<table width="50" cellspacing="0" cellpadding="0" border="1">
    <tr>
    <th width="50" height="50" scope="col"><a href="product.php?id=' . $id . '">
    <img src="inventory_images/' . $id . '.jpg" width="50" height="50" border="0" /></a></th>
    </tr>
    </table>';
    if(isset($_SESSION['recentlyVieweded']))
    $_SESSION['recentlyVieweded']=$_SESSION['recentlyVieweded']+1;
    else
    $_SERVER['recentlyVieweded']= 1;
    echo "".$_SESSION['recentlyViewed']."";
    ?> 

    post-133640-0-94421000-1381689604_thumb.jpg

  8. I need some a little help can't seem to find my own error ....What I'm trying to go for is a size select drownbox so when someone select Small,Medium or Large from Form1 that selection then gets pushed into my Cart Array along with my items id and quantity but for some reason I keep getting

     

    Notice: Undefined variable: sizeList in /home/content/72/10029872/html/cart.php on line 21

     

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/72/10029872/html/cart.php:21) in /home/content/72/10029872/html/cart.php on line 38 array

     

    <!------- HTML FORM --------->

    <form id="form1" name="form1" method="post" action="cart.php">

    <select name="size">

    <option value="1">Small</option>

    <option value="2">Medium</option>

    <option value="3">Large</option>

    input type="hidden" name="pid" id="pid" value="<?php echo $sizeList; ?>" />

    </select>

    <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />

    <input type="submit" name="button" id="button" value="Add to Shopping Bag" />

    </form>

    <!------- PHP CART ARRAY ------->

    <?php

    if (isset($_POST['pid'])) {

    $pid = $_POST['pid'];

    $wasFound = false;

    $i = 0;

    // If the cart session variable is not set or cart array is empty

    if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {

    // RUN IF THE CART IS EMPTY OR NOT SET

    $_SESSION["cart_array"] = array(0 => array("item_id" => $pid, "quantity" => 1, "size" => $sizeList));

    } else {

    // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT

    foreach ($_SESSION["cart_array"] as $each_item) {

    $i++;

    while (list($key, $value) = each($each_item)) {

    if ($key == "item_id" && $value == $pid) {

    // That item is in cart already so let's adjust its quantity using array_splice()

    array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "quantity" => $each_item['quantity'] + 1)));

    $wasFound = true;

    } // close if condition

    } // close while loop

    } // close foreach loop

    if ($wasFound == false) {

    array_push($_SESSION["cart_array"], array("item_id" => $pid, "quantity" => 1));

    }

    }

    header("location: cart.php");

    exit();

    }

    ?>

  9. I would suggest adding an email alert system for when someone replies you an post you've created .... Lets say Billy posted a problem about his tables aren't working in html...Once someone reply to Billy's topic that reply then gets filtered to Billy's email address verifying him that someone has left an post on his topic..... that way Billy gets the help he needs so he doesn't have to do this to his pc because his codes aren't working right lol :hammer_time:

  10. I'm creating a test clothing site and i was wondering should I trying to use Mysql or POST / or GET Forms to transfer data from page to page

     

    Let me explain what I'm trying to achieve here. I'm trying to let customers select which size they would like from Small, Medium, or Large. Once they've selected their size from the product page that information / data then gets transfer to the cart and loop over again so it doesn't go away when the customers continue to shop for more items.... anyways when they're finish I would then like the size to render out into paypal checkout so I the manager / admin would what size they'll need for shippment

     

    If you prefer Myql how would I set this up

    or POST / or GET Forms what step would I take for it to render out in paypal ?

     

     

    Untitled-2-2.jpg

  11. might not agree with me on this but I would have used <div> and <table> method because tables is still effective if you ask me.. plus its faster and away clean .....anways next time when you're designer a website using all divs press ctrl + you'll see your divs tend to move across the page because there's not container around it or them to hold them in place...I've seen your site and saw some of your work slide out of place....

     

    <div align="center" id="wrapper" width"" height"">

    <table>

     

    </table>

    </div>

    1. Tally The Total Error When I tally the total with an quantity of 2 my php calculate turn short up in php...But when I press the checkout button to paypal everything adds up correctly.....
    2. Shipment Trouble When I can add 2 or more items to my cart and checkout with paypal my shipment increase to another 10.00 dollars How would I fix that to remain 10.00?
    3. Tax calculate error the more items I add to my database my shipment changes from 0.08% to 0.02%

    How Would I fix these errors without any bugs ?

    $shipTotal="10.00";

    $taxRate ="0.08";

    $pricetotal = $price * $each_item['quantity'];

    $getTax = $price * $taxRate;

    $cartTotal = $pricetotal + $getTax + $shipTotal + $cartTotal ;

    setlocale(LC_MONETARY, "en_US");

    $pricetotal = money_format("%10.2n", $pricetotal);

    // Dynamic Checkout Btn Assembly

    $x = $i + 1;

    $pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '">

    <input type="hidden" name="amount_' . $x . '" value="' . $price . '">

    <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '">

    <input type="hidden" name="shipping_'. $x . '"value="'. $shipTotal .'">

    <input type="hidden" name="tax_'. $x . '"value="'. $taxRate * $price .'"> ';

    // Create the product array variable

    $product_id_array .= "$item_id-".$each_item['quantity'].",";

×
×
  • 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.