Form specific to Cookie in users computer

Hi,

If a basket has content specific to the users computer this makes sense. So, if they come back at a later time (within cookie expiration) they can see the same info in their basket. Or if the add more than one thing, it stores previously added products.

But when they click to proceed from the basket I intend to have a form like the one below but how do I make it cookie specific so the customer information is added to the correct row in the MySQL Database?:


<form  class="formtest" id="form1" method="post" action="">
    <fieldset>
    <legend>Customer Details</legend>
    <label for="emailaddress">Email Address:</label>
    <input type="text" name="emailaddress" id="emailaddress" />
    <br />
    <label for="firstname">First Name:</label>
    <input type="text" name="firstname" id="firstname" />
    <br />
    <label for="lastname">Last Name:</label>
    <input type="text" name="lastname" id="lastname" />
    <br />
    <label for="address1">Address 1:</label>
    <input type="text" name="address1" id="address1" />
    <br />
    <label for="address2">Address 2:</label>
    <input type="text" name="address2" id="address2" />
    <br />
    <label for="address3">Address  3:</label>
    <input type="text" name="address3" id="address3" />
    <br />
    <label for="address4">Address 4:</label>
    <input type="text" name="address4" id="address4" />
    <br />
    <label for="city">City:</label>
    <input type="text" name="City" id="city" />
    <br />
    <label for="state">State:</label>
    <input type="text" name="state" id="state" />
    <br />
    <label class="zip" for="zip">Zip:</label>
    <input type="text" name="zip" id="zip" />
    <br />
    <label for="tel">Telephone:</label>
    <input type="text" name="tel" id="tel" />
    <br />
    </fieldset>
    <fieldset class="gender">
    <legend>Enter Gender</legend>
    <input type="radio" name="radio" id="rad1" value="rad1" />
    <label for="rad1">Male</label>
    <br />
    <input type="radio" name="radio" id="rad2" value="rad2" />
    <label for="rad2">Female</label>
    <br />
    <input type="radio" name="radio" id="rad3" value="rad3" />
    <label for="rad3">Not sure</label>
    <br />
    <input type="submit" value="submit" />
    </fieldset>
</form>

It needs to add this content in a MySQL table in a row where the cookie in their computer matches the cookie code stored in the MySQL table.

I think I need to use the code: where cookieid = ‘" . GetCartId() . "’ in the code below but how do I do it when using a form!?!

$query = mysql_query("SELECT COUNT(*) FROM cart where cookieid = '" . GetCartId() . "' and productid = $ID");

Matt.

then how would you do it?

no, the customer would not have to log in.

I think you refer to having login details for customers, which I am not keen on. I prefer to just let the user order simply - click add to basket, click checkout, enter their details and card info - simple.

Cookies enables this. Your method does not, right?

Matt.

This appears to be the same or similar question to the one you ask in your other thread.

Why are you using cookies? If a user has cookies disabled in their browser or clears their browser cache before the cookies expire then they won’t be able to store the contents of their basket.

Also, using cookies stops the user from coming back on a different pc.

If you want to store a user’s basket contents for a future return visit, you will be better off storing the basket’s contents for the user in the database and not cookies. Then it won’t matter whether cookies are enabled or deleted and the user has the flexibility of returning in the future from another pc and still have access to their basket’s contents from their previous visit.