Hello again
Can anybody tell me if php has a function that will detect what page a user has come from?
Ive several page on my site from which a user can add to their cart. Once they click an add to cart button from any page they will be sent to a script which adds data to the cart table and redirects them automatically to the showcart page. I want to change this so that after the info has been added to the cart table the user is redirected to the page they added to cart from. Any Ideas?????
here is the add to cart script
PHP Code:
<?php
session_start();
include('dbinfo.php');
$query = "SELECT * FROM $_POST[table] WHERE item_ID='$_POST[item_id]' and size='$_POST[size]'";
$result = mysql_query($query)
or die("Query failed: " . mysql_error());
while ( $row = mysql_fetch_array($result) ) {
$item_id= $row[item_id];
$item=$row[item];
$one_weight=$row[weight];
$description= $row[description];
$one_price= $row[price];
}
$system_name="$_SESSION[sysname]";
$overall_aperture="$_SESSION[apwidth]x$_SESSION[apheight]";
$hinged_or_sliding="$_SESSION[hingeslid]";
$finish="$_POST[finish]";
$extras="$_POST[extras]";
$quantity="$_POST[quantity]";
$size="$_POST[size]";
$weight=($one_weight * $quantity);
$price=($one_price * $quantity);
$insert = "INSERT INTO cart_items VALUES (''
,'$PHPSESSID','$system_name','$item_id','$item','$weight'
,'$overall_aperture','$size','$hinged_or_sliding','$finish','$extras'
,'$quantity','$price')";
mysql_query($insert);
mysql_close();?>
<?php header("Location: SEND_TO_PREVIUOS_PAGE.php"); exit; ?>
|