Jump to content

vinpkl

Members
  • Posts

    448
  • Joined

  • Last visited

Posts posted by vinpkl

  1. yes gevan

     

    The unique id or session id is not generated everytime user login in.

     

    I m using unique id everywhere like in my cart table and order table and managing the records acording that unique id. At the time customer add to product to cart and then proceed to order the unique id in cart and order will be the same. Its not generated when he logs in but it should be destroyed when logs out.

     

    $unique_id=session_id is on everypage. so when user click add to cart buton then also the session id gets inserted into the cart table and so is like with order table when the user goes from cart to order at the time the same unique wil go to order table.

     

    i want it to delete it when user logs out.

     

    vineet

  2. hi gevans

     

    this is the qry i m using for inserting record

    $qry="insert into new_order(unique_id,order_date,customer_name) values('$unique_id', curdate(), '$username')";
    mysql_query($qry);
    

     

    in this unique_id is the session id. on logout i want that this unique id that is the session id should be generated everytime new otherwise everyrecord is getting inserted in the record that has old session id.

     

    vineet

  3. hi gevans

     

    i looked at your reference. can you tell me how to use it

     

    it has

    $old_sessionid = session_id();
    session_regenerate_id();
    $new_sessionid = session_id();
    

     

    do i need to have two separte fields in my database, one for old session and second for new session.

     

    actually i m using the session id as unique id in my database. Like i m inserting a order in my database, that order will have 3 products or 3 rows and all 3 products and rows will have same unique id.

    In my script if evertime the products or rows inserted are having new unique id then the order id is automatically assumed as new order and the products are added in new order otherwise products get added in old order.

     

    $qry="insert into new_order(unique_id,order_date,customer_name) values('$unique_id', curdate(), '$username')";
    

     

    vineet

  4. hi all

     

    i m using

    $unique_id = session_id(); 
    

     

    to get new unique id for my records. Everytime i close the whole browser and open new browser i get a new unique_id.

     

    I am not able to destroy the old unique id on logout and get new unique id in my record when i login.

    If i have to get a new unique id i have to close all tabs of the browser or say whole browser and open the site again in new browser.

     

    I have session_start(); in my config file that is included on all pages.

     

    This is my logout script

    <? require_once("config.php");
    $unique_id = session_id(); 
    $qry="delete from cart_table where unique_id='$unique_id'";
    mysql_query($qry);
    $_SESSION = array(); 
    session_unset();
    session_destroy();
    header("Location:index.php"); 
    ?>
    

     

    vineet

  5. ur code seems to produce single result since u have not used loop 
    while($row_del=mysql_fetch_array($result_del))
    {
    $qry_del="DELETE from order_detail_table where order_id='$order_id' AND product_name='$product_name'";
    echo $qry_del;
    
    }
    
    

     

    hi zenag

     

    i tried putting while loop. but it gaves me same result. it also deletes the product at no.1 not the particular product selected.

     

    <?php
    if(isset($_REQUEST['del_item_x']))
    {
    $qry_del="select * from order_detail_table";
    $result_del=mysql_query($qry_del);
    $row_del=mysql_fetch_array($result_del);
    $order_id=$row_del['order_id'];
    $product_name=$row_del['product_name'];
    //echo "test". $row_del['order_id'];
    while($row_del=mysql_fetch_array($result_del))
    {
    $qry_del="DELETE from order_detail_table where order_id='$order_id' AND product_name='$product_name'";
    echo $qry_del;
    }
    //echo $qry_del;
    if(mysql_query($qry_del))
    {
    $msg="item deleted success";
    }
    else
    {
    $msg="item not deleted";
    }
    }
    ?>
    

     

    vineet

  6. hi gmcalp

     

    thanks for reply.

     

    The problem is that when i need to delete all products of one id in single click then it works fine. The delete button deletes all products of same id.

     

    I need to delete the particular item of that id. here i am facing trouble.

     

    vineet

     

    Here's the delete from table that I have in one of my scripts:

     

    while ($row = mysql_fetch_array($result)) {
       $jobid = $row['id'];
       $jobtitle = $row['title'];
       $added = $row['added'];
       $empl = $row['employer'];
       echo '<p>' . $jobtitle . ", " . $empl . ": " . $added .
           ' <a href="' . $_SERVER['PHP_SELF'] .
           '?deletejob=' . $jobid . '">' .
           'Delete this job</a></p>';}
    }
    
    
    // If a job has been deleted,
    // remove it from the database.
    if (isset($_GET['deletejob'])) {
       $jobid = $_GET['deletejob'];
       $sql = "DELETE FROM jobs WHERE id=$jobid";
       if (@mysql_query($sql)) {
    
         echo "<b>Job Deleted!<br>You'll be redirected to Home Page after (4) Seconds";
         #header("location: deleted.php");
         echo "<meta http-equiv=Refresh content=4;url=".$_SERVER['PHP_SELF'].">";
    #     $_SERVER['PHP_SELF'];

     

    Edit it as you need.

  7. hi golden eye

     

    i tried using order_id inside the qry

    this is the code

    <?php
    if(isset($_REQUEST['del_item_x']))
    {
    $qry_del="select * from order_detail_table";
    $result_del=mysql_query($qry_del);
    $row_del=mysql_fetch_array($result_del);
    $order_id=$row_del['order_id'];
    $product_name=$row_del['product_name'];
    //echo "test". $row_del['order_id'];
    $qry_del="DELETE from order_detail_table where order_id='$order_id' AND product_name='$product_name'";
    echo $qry_del;
    if(mysql_query($qry_del))
    {
    $msg="item deleted success";
    }
    else
    {
    $msg="item not deleted";
    }
    }
    ?>
    

     

    Like i have product name nokia on no.1 and samsung on no.2.

    when i echo the result after clicking delete button on samsung i get

    <?php
    DELETE from order_detail_table where order_id='67' AND product_name='nokia' 
    ?>
    

     

    vineet

     

  8. hi all

     

    I m working in admin section.

    There i have order details rows. i have a option of deleting the record on clicking the delete button with each row.

    Everytime when i click delete button it deletes the record that is on no.1 not the particular record that i selected. whether i select the delete button at row 5 then also it deletes the record of row 1.

     

    this the code

    <?php
    if(isset($_REQUEST['del_item_x']))
    {
    $qry_del="select * from order_detail_table";
    $result_del=mysql_query($qry_del);
    $row_del=mysql_fetch_array($result_del);
    $order_id=$row_del['order_id'];
    $product_name=$row_del['product_name'];
    //echo "test". $row_del['order_id'];
    $qry_del="DELETE from order_detail_table where product_name='$product_name'";
    echo $qry_del;
    if(mysql_query($qry_del))
    {
    $msg="item deleted success";
    }
    else
    {
    $msg="item not deleted";
    }
    }
    ?>
    

     

    vineet

  9. hi gevans

     

    i would like to ask you one more question.

    I have 3 row results in my order table and i when i echo them in the loop then i get only two row result with same query for three.

     

    But when i write

    <?php
    echo mysql_num_rows($result_p);
    ?>
    

    then i get result as 3. That is corect number of rows. If this is corect then why i am not able to print 3 rows. i m able to print only 2 rows.

     

    This is my code without email. just for test

    <?php
    $qry_p="select * from order_detail_table where customer_name='$log_id'";
    $result_p=mysql_query($qry_p);
    $row_p=mysql_fetch_array($result_p);
    
    //echo mysql_num_rows($result_p); //this is giving me corect result.
    
    while($row_p=mysql_fetch_array($result_p))
    {
    $product_name=$row_p['product_name'];
    $quantity=$row_p['quantity'];
    $shipping=$row_p['shipping'];
    $price=$row_p['price'];
    $total_cost=$row_p['total_cost'];
    //echo $qry_p ."<br>". $product_name.",".$quantity.",".$shipping.",".$price."<br>";
    }
    
    ?>
    

     

    what could be the reason and how can i find out.

     

    vineet

     

  10. Hi vinpkl,

     

    You should include some error checks in you code to ensure that it's all working properly, for example;

    <?php
    $qry_p="select * from order_detail_table where customer_name='$log_id'";
    $result_p=mysql_query($qry_p);
    if (!$result_p) die('Invalid query: ' . mysql_error());
    ?>
    

     

    Try adding this and make sure it runs properly. Do you mean that the email currently has no product details when sent?

     

    hi

     

    thanks for reply. i wil include that in my script.

    The email at present send information of only one product.

     

    <?php
    $qry_p="select * from order_detail_table where customer_name='$log_id'";
    $result_p=mysql_query($qry_p)or die (mysql_error()); 
    $row_p=mysql_fetch_array($result_p);
    while($row_p=mysql_fetch_array($result_p))
    {
    $product_name=$row_p['product_name'];
    $quantity=$row_p['quantity'];
    $shipping=$row_p['shipping'];
    $price=$row_p['price'];
    $total_cost=$row_p['total_cost'];
    }
    ?>
    

     

    vineet

  11. hi all

     

    i have an created email function that sends the product information from shopping cart to the customer.

     

    i have inserted loop outside the body of email that is showing all the results of products in loop corectly.

     

    But i m not able to send that loop results in the email as i m not able to insert that loop in the email body. my email script is here

     

    
    <?php
    if(isset($_REQUEST['submit']))
    {
    $qry_p="select * from order_detail_table where customer_name='$log_id'";
    $result_p=mysql_query($qry_p);
    $row_p=mysql_fetch_array($result_p);
    while($row_p=mysql_fetch_array($result_p))
    {
    $product_name=$row_p['product_name'];
    $quantity=$row_p['quantity'];
    $shipping=$row_p['shipping'];
    $price=$row_p['price'];
    $total_cost=$row_p['total_cost'];
    }
    
    $to= $customer_log_id;
    $subject= "Shopping Order details with gadgetsonline.co.nz";
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From:vineet@domain.com' . "\r\n";
    
    
    $body="This is a detail bill.".  " \n<br><br>
    -----------------------------------------------------------" ." \n<br>
    Product Details : ". " \n<br>
    Product Name = " .$product_name . " \n\n<br>
    Quantity = " .$quantity . " \n<br>
    Shipping cost= ".$shipping. " \n<br>
    Price= ".$price. " \n<br>
    Total cost= ".$total_cost. " \n<br>
    Payment Status =". "Pending";
    
    if(mail($to,$subject,$body,$headers))
    $msg2= "order mail sent!"; 
    else
    $msg2= "order mail not sent!";	
    }	
    ?>
    
    

  12. I'm not sure of the limits to javascript's "onunload" .. butyou could try something like:

     

    <script type="text/javascript">
    function clearCart() {
        // try to make an ajax call to say 'clearcart.php' ..
    }
    </script>

     

    Then just add:

     

    <body onunload="clearCart();">

     

    When the clearCart() function is called the page will have already unloaded, so I'm not sure if there any limits in what you can do, but worth a shot!

     

    Adam

     

    HI ADAM

     

    thanks for reply. but i dont know anything about ajax.

     

    vineet

  13. hi all

     

    i am looking for a function that clears the contents of the shopping cart on closing the browser and displays an confirm alert before removing the contents.

     

    i have a script that clear contents on clicking the clear cart button but i need to have the same option on closing the browser.

     

    this is my script

    if(isset($_REQUEST['clear_cart_x']))
    {
    $product_id=$row['product_id'];
    $image=$row['image'];
    $product_name=$row['product_name'];
    $price=$row['price'];
    $shipping_cost=$row['shipping_cost'];
    $quantity=$row['quantity'];
    $total_cost=$row['total_cost'];
    $qry="delete from cart_table where unique_id='$unique_id'";
    mysql_query($qry);
    }
    

     

    vineet

  14. The "new" indicator means that you've read it and there has been no new posts since you read the thread. When you've created a thread you've obviously read it so the "new" indicator won't be there.

     

    hi

     

    thanks for reply.

     

    I understood your answer But i can still see that the threads which have 10 views and 10 replies they also have "new" blue colour icon with their headings.

    means the threads which have been read 10 times they still have "new" blue colour icon with their headings.

     

    vineet

  15. Hi all

     

    I am working on a shopping cart module. At present my script add a product in cart and if its already in the cart then it updates the quantity.

     

    This works well for the single visitor to the website. But if there are multiple visitors or users at the same time then it will mess up the cart contents with others.

     

    what should i add in my script.

     

    This is my shopping cart script

    <?php 
    require_once("config.php"); 
    
    $_SESSION['product_id']=$_REQUEST['product_id']; 
    $id=$_SESSION['product_id'];
    $id=$_REQUEST['id'];
    echo $id;
    
    $qry="SELECT * FROM product_table WHERE product_id=$id";
    $result=mysql_query($qry)or die (mysql_error()); 
    $row=mysql_fetch_array($result);
    
    $pid=$id;
    $image=$row['image'];
    $product_name=$row['product_name'];
    $price=$row['price'];
    $shipping_cost=$row['shipping_cost'];
    $total_cost=$row['price']+$row['shipping_cost'];
    
    $qry="SELECT product_id from cart_table where product_id=$id";
    $result=mysql_query($qry)or die (mysql_error()); 
    $row=mysql_fetch_array($result);
    
    if($id != $row['product_id'])
    {
    $qry="INSERT INTO cart_table(product_id,image,product_name,price,quantity,shipping_cost,total_cost) 
    VALUES($id,'$image', '$product_name', $price, 1, $shipping_cost, $total_cost)";
    $result=mysql_query($qry)or die(mysql_error());
    }
    else
    {
    $qry="UPDATE cart_table SET product_id=$pid,image='$image',product_name='$product_name',price=$price,quantity=quantity+1,shipping_cost=$shipping_cost,total_cost=$total_cost where product_id=$id"; 
    $result=mysql_query($qry)or die(mysql_error());
    }
    ?>
    

     

    vineet

  16. hi

     

    my user id is vinpkl.

    When ever i post any new thread then my thread never gets a "new" image with its heading.

     

    means in other new threads there is a image in which its mentioned "new" in the thread heading in php help section (link given below)

     

    http://www.phpfreaks.com/forums/index.php/board,1.0.html

     

    but my thread never gets this "new" image attached with my thread heading that conveys that this is my new thread, it always conveys my thread is old.

     

    how can i get it.

     

    is it because i never logout. i m login forever

     

    vineet

  17. The type int(5) only stores numbers. '03' is a string, not a number. It's a visual representation of the number three.

     

    To solve this, you can either change the type in the database to a varchar, or still store it as a number and convert it to a string with a leading zero after retrieving it from the database.

     

    hi jeremysr

     

    thanks for the reply. now i understood what to change.

     

    vineet

     

  18. hi all

     

    i have a <select> with options for area code in my form.

    In the database i have its datatype as int(5).

     

    when i select any option and submit form then i get the area code result as "3" or "4" or "5" in my database.

     

    How can i get the area code result as "03" or "04" or "05"

     

    here is the <select> code

    <select name="customer_contact_code" id="customer_contact_code">
    <option value=""> </option>
    <option value="03">03</option>
    <option value="04">04</option>
    <option value="06">06</option>
    <option value="07">07</option>
    <option value="09">09</option>
    </select>
    

     

     

    vineet

  19. did all the info get entred into the database mate....

     

    cheek the id ok

     

    hi redarrow

     

    nothing got inserted into the cart table.

     

    also tell where we have writen $sql should it be $qry=

    $sql="SELECT `product_id`,`image`,`product_name`,`price`,`shipping_cost` FROM `product_table` WHERE `product_id`='$id'";
    

    because in the bottom we are writing $qry=.

     

    also this is the code i m writing on my add to cart button.

    <?php 
    echo "<a href=shopping_cart.php?id=" . $row['product_id'] . ">" ."<img src='images/add_cart.gif' border=0 />" . "</a>" . "</td>";
    
    ?>
    

     

    vineet

  20. Try this please........

     

    <?php session_start();
    
       require_once("config.php"); // if the session_start() in here dont use it, use it on it own each page...
       
       $_SESSION['product_id']=$_GET['product_id']; // use get or post only request no good get from url or post from form.
       
       $id=$_SESSION['product_id'];
      
       $sql="SELECT `product_id`,`image`,`product_name`,`price`,`shipping_cost` FROM `product_table` WHERE `product_id`='$id'";
       $result=mysql_query($qry)or die (mysql_error()); //add the error function.
       
       while(mysql_fetch_assoc($result)){
       
       $qry="INSERT INTO `cart_table`(`product_id`,`image`,`product_name`,`quantity`,`price`,`shipping_cost`,`total_cost`) 
       VALUES('$id','".$row['image']."','".$row['product_name']."',1,'".$row['price']."','".$row['shipping_cost']."'
       ,'".$row['price']+$row['shipping_cost']."')";
      $result2=mysql_query($qry)or die(mysql_error());//add error function
       
       }
    ?>
    
    

     

    Hi redarrow

     

    thanks for the reply. it worked with no error.

     

    But gives the result as "query was empty".

     

    what does this means

     

    vineet

  21. okay what are the data types of

     

    cart_table( product_id

                    image

                    product_name

                    quantity

                    price

                    shipping_cost

                    total_cost

     

    hi

     

    here is the datatypes in cart table

     

    cart_id = int(10) autoincrement

    product_id=int(20)

    image = varchar(40)

    product_name = varchar(40)

    price = float(9,2)

    quantity = int(10)

    shipping_cost = float(9,2)

    total_cost = float(9,2)

     

    vineet

     

  22. you have to remember to enQuote your string/charactor values with quotes and leave you numeric values open

     

    <?php
    $qry="insert into cart_table(product_id,image,product_name,quantity,price,shipping_cost,total_cost) values(".$id.",'".$row['image']."','".$row['product_name']."',1,".$row['price'].",".$row['shipping_cost'].",".$row['price']."+".$row['shipping_cost'].")";
    ?>
    

     

    i think thats it im not sure of your db structure though also if your hardcoding your quantity value don't quote it out

     

    Hi n3ightjay

     

    i used it and received this

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\xampp\htdocs\vineet\shopping_cart.php on line 12
    insert into cart_table(product_id,image,product_name,quantity,price,shipping_cost,total_cost) values(,'','',1,,,+)
    

     

    this is line 12

    $row=mysql_fetch_array($result);
    

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