cookie/kurv.php:
<?php
function GetCartId() {
// This function will generate an encrypted string and
// will set it as a cookie using set_cookie. This will
// also be used as the cookieId field in the cart table
if(isset($_COOKIE["cartId"])) {
return $_COOKIE["cartId"];
} else {
// There is no cookie set. We will set the cookie
// and return the value of the users session ID
session_start();
setcookie("cartId", session_id(), time() + (3600 * 24));
return session_id();
}
}
?>
bekræftelse.php:
<?php require_once('Connections/web3.php'); ?>
<?php
mysql_select_db($database_dk, $dinside_dk);
include("cookie/kurv.php");
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup, $Variabel) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers) && $_SESSION[place] == $Variabel) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups) && $_SESSION[place] == $Variabel) {
$isValid = true;
}
if (($strUsers == "") && true && $_SESSION[place] == $Variabel) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login.php";
mysql_select_db($database_dk, $dinside_dk);
$query_rsSite = sprintf("SELECT sitenavn FROM web3_info WHERE id = 1");
$rsSite = mysql_query($query_rsSite, $dinside_dk) or die(mysql_error());
$row_rsSite = mysql_fetch_assoc($rsSite);
$totalRows_rsSite = mysql_num_rows($rsSite);
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'], $row_rsSite['sitenavn'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
mysql_select_db($database_dk, $dinside_dk);
$query_rsKategorier = sprintf("SELECT id, varekategori FROM web3_varekategorier ORDER BY varekategori");
$rsKategorier = mysql_query($query_rsKategorier, $dinside_dk) or die(mysql_error());
$row_rsKategorier = mysql_fetch_assoc($rsKategorier);
$totalRows_rsKategorier = mysql_num_rows($rsKategorier);
$query_rsSite = sprintf("SELECT * FROM web3_info WHERE id = 1");
$rsSite = mysql_query($query_rsSite, $dinside_dk) or die(mysql_error());
$row_rsSite = mysql_fetch_assoc($rsSite);
$totalRows_rsSite = mysql_num_rows($rsSite);
$kunde = $_GET['bruger'];
$query_rsKunder = sprintf("SELECT * FROM web3_kunder WHERE brugernavn ='%s'", $kunde);
$rsKunder = mysql_query($query_rsKunder, $dinside_dk) or die(mysql_error());
$row_rsKunder = mysql_fetch_assoc($rsKunder);
$totalRows_rsKunder = mysql_num_rows($rsKunder);
$result = mysql_query("SELECT * FROM web3_kurv INNER JOIN web3_varer ON web3_kurv.vareid = web3_varer.id WHERE web3_kurv.cookieid = '" . GetCartId() . "' ORDER BY web3_varer.navn ASC") or die(mysql_error());
$totalRows_rsResult = mysql_num_rows($result);
$query_rsMaxFakturaNr = sprintf("SELECT MAX(faktura) AS max FROM web3_faktura");
$rsMaxFakturaNr = mysql_query($query_rsMaxFakturaNr, $dinside_dk) or die(mysql_error());
$row_rsMaxFakturaNr = mysql_fetch_assoc($rsMaxFakturaNr);
$totalRows_rsMaxFakturaNr = mysql_num_rows($rsMaxFakturaNr);
$naeste = $row_rsMaxFakturaNr['max']+1;
while($row = mysql_fetch_array($result)) {
mysql_query("INSERT INTO web3_faktura (faktura, kundeid, vareid, antal, tid) VALUES (".$naeste.", ".$row_rsKunder['id'].", ".$row['id'].", ".$row['antal'].", now())") or die(mysql_error());
}
echo $_COOKIE["cartId"];
echo '<br>';
setcookie("cartId", "", time()-3600);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo $row_rsSite['sitenavn']; ?> - Netbutik</title>
<link href="elements.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
margin-top: 0px;
}
-->
</style>
</head>
<body background="pics/web3_body_bg.jpg">
<table cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF">
<tr>
<td width="20" style="background-image:url(pics/sider_bg.jpg); background-position:left; background-repeat:repeat-y;"></td>
<td>
<table style="width:890px;" cellpadding="0" cellspacing="0">
<tr>
<td>
<table style="width:890px; height:50px; vertical-align:middle;" cellpadding="0" cellspacing="0">
<tr>
<td style="padding-left:25px;"><a href="index.php"><img src="pics/firmanavn.jpg" border="0" align="left"></a></td>
<td width="3"></td>
<td width="30"><a href="mailto:<?php echo $row_rsSite['mail']; ?>"><img src="pics/kuvert.jpg" border="0" alt="send mail"></a></td>
<td width="30"><a href="java script:window.print()"><img src="pics/udskriv.jpg" border="0" alt="udskriv siden"></a></td>
<td width="30" style="padding-right:30px;"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align:center;"><img src="pics/header.jpg" style="border:1px solid #cccccc; padding:2px;"></td>
</tr>
<tr>
<td style="text-align:right; padding-top:10px; padding-right:10px;">
<form name="form1" method="get" action="netbutikresult.php" style="display:inline;">
<table width="200" border="0" cellspacing="0" cellpadding="0" align="right">
<tr>
<td><input name="search" type="text" id="search" style="font-size:9px;"> </td>
<td><input type="submit" name="Submit" value="Søg efter vare" style="font-size:9px;"></td>
</tr>
</table>
</form>
</td>
</tr>
<tr style="height:10px;"><td></td></tr>
<tr>
<td width="890px">
<table style="width:100%;" cellpadding="0" cellspacing="0">
<tr>
<td style="width:20%; padding-top:50px; vertical-align:text-top;">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<table cellpadding="1" cellspacing="1" align="left" style="width:100%; border:1px solid #cccccc;">
<?php do { ?>
<tr>
<td height="15" style="padding-left:25px; background-color:#F4F4FD;"><a href="netbutik.php?cat=<?php echo $row_rsKategorier['id']; ?>" class="menu_link"><?php echo $row_rsKategorier['varekategori']; ?></a></td>
</tr>
<?php } while ($row_rsKategorier = mysql_fetch_assoc($rsKategorier)); ?>
</table>
</td>
</tr>
</table>
</td>
<td style="width:5%;"></td>
<td valign="top" style="width:75%;">
<table cellpadding="1" cellspacing="2" width="100%" style="border:1px solid #cccccc;">
<tr>
<td class="web3_box_headline">Ordrebekræftelse</td>
</tr>
<tr>
<td class="web3_box_content" style="font-size:10px;">
Din ordre er nu gennemført. Mange tak for din bestilling.<br>
Du vil modtage en ordrebekræftelse på <i><?php echo $row_rsKunder['email']; ?></i>.<br>
<br><br><br>
<table cellpadding="0" cellspacing="0" id="TekstBox" width="100%">
<tr>
<td colspan="6"><hr></td>
</tr>
</table><br>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan="2" style="font-size:10px; font-style:italic;" align="center">Priserne er inkl. moms.<br>
Der tages forbehold for trykfejl, udgåede varer, udsolgte varer og ændringer i produktspecifikationer.
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr style="height:30px;"><td></td></tr>
<tr>
<td>
<table cellpadding="1" cellspacing="1" style="width:890px; background-color:#E7E2F3; border:1px solid #cccccc;">
<tr>
<td align="center" style="font-size:11px; color:#666666;"><?php echo $row_rsSite['sitenavn']; ?><?php if ($row_rsSite['tlf'] != NULL){ ?> - <?php } ?><?php if ($row_rsSite['tlf'] != NULL){ ?> Tlf: <?php echo $row_rsSite['tlf']; } ?><?php if ($row_rsSite['mail'] != NULL){ ?> - <?php } ?><?php if ($row_rsSite['mail'] != NULL){ ?>E-mail: <a href="mailto:<?php echo $row_rsSite['mail']; ?>" class="a1" style="font-size:11px;"><?php echo $row_rsSite['mail']; ?></a><?php } ?></td>
</tr>
</table>
</td>
</tr>
<tr style="height:20px;"><td></td></tr>
</table>
</td>
<td width="20" style="background-image:url(pics/sider_bg.jpg); background-position:right; background-repeat:repeat-y;"></td>
</tr>
<tr>
<td colspan="3" style="height:2px; background-image:url(pics/bottom_bg.jpg); background-repeat:repeat-x;"></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsSite);
mysql_free_result($rsKategorier);
mysql_close();
?>
Håber du kan overskue det...