Ok, so ErnieAlex here I am again 
If anyone wants to see what Im trying to do here have a look at this:
http://www.phphelp.com/forum/index.php?topic=16113.15
OK, so I am creating a dvd shop, when someone clicks on the buy now button beside every product I want their details to be sent to a transactions table. The transactions table will have the customerID, productID, product_name and price. Instead of them having to fill in a form, I am wanting the data to be sent to the table automatically when they click the buy button.
I will put the code below that is on the product page for each individual product.
Thanks.
[php]<?php
session_start();
if(!isset($_SESSION[āmemberā])){
header(ālocation: memberlogin.phpā);
exit();
}
$customerID = preg_replace (ā#[^0-9]#iā, āā, $_SESSION[ācustomerIDā]); //filter everything but numbers and letters
$member = preg_replace (ā#[A-Za-z0-9]#iā, āā, $_SESSION[āmemberā]); //filter everything but numbers and letters
$password = preg_replace (ā#[A-Za-z0-9]#iā, āā, $_SESSION[āpasswordā]); //filter everything but numbers and letters
//check to see the url variable is set and it exists in database
if(isset($_GET[āidā])){
$id = preg_replace(ā#[^0-9]#iā, āā, $_GET[āidā]);
include āstorescripts/connect_to_mysql.phpā;
$sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");
$productCount = mysql_num_rows($sql);
if ($productCount > 0){
while($row = mysql_fetch_array($sql)){
$product_name = $row['product_name'];
$price = $row['price'];
$product_details = $row['product_details'];
$category = $row['category'];
$subcategory = $row['subcategory'];
}
} else {
echo "No product with that id";
exit();
}
} else {
echo āNo product with that idā;
exit();
}
mysql_close();
?>
<?php echo $product_name; ?>Price: Only Ā£<?php echo $price; ?> Category: <?php echo $category; ?> Subcategory: <?php echo $subcategory; ?> Product Details: <?php echo $product_details; ?> Ā
|
Iām sure you can guess now by the amount of questions I have asked that Iām not the best at this. If it doesnāt bother you too much or take too much time, would you by any chance be able to post some code as an.example. if it takes too long then not to worry.