Jeg har fundet et tutorial med en shopping cart, men i den er der ikke en checkout, så derfor har jeg prøvet at lave en selv. men uden held.... så derfor spørger jeg alle jer, om der er nogen der vil lave den for mig....
Jeg poster de sider jeg har, og så skal der bare laves færdig.
cart.php
<?php
include("db.php");
switch($_GET["action"])
{
case "add_item":
{
AddItem($_GET["id"], $_GET["qty"]);
ShowCart();
break;
}
case "update_item":
{
UpdateItem($_GET["id"], $_GET["qty"]);
ShowCart();
break;
}
case "remove_item":
{
RemoveItem($_GET["id"]);
ShowCart();
break;
}
default:
{
ShowCart();
}
}
function AddItem($itemId, $qty)
{
// Will check whether or not this item
// already exists in the cart table.
// If it does, the UpdateItem function
// will be called instead
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
// Check if this item already exists in the users cart table
$result = mysql_query("select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This item doesn't exist in the users cart,
// we will add it with an insert query
@mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)");
}
else
{
// This item already exists in the users cart,
// we will update it instead
UpdateItem($itemId, $qty);
}
}
function UpdateItem($itemId, $qty)
{
// Updates the quantity of an item in the users cart.
// If the qutnaity is zero, then RemoveItem will be
// called instead
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
if($qty == 0)
{
// Remove the item from the users cart
RemoveItem($itemId);
}
else
{
mysql_query("update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId");
}
}
function RemoveItem($itemId)
{
// Uses an SQL delete statement to remove an item from
// the users cart
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId");
}
function ShowCart()
{
// Gets each item from the cart table and display them in
// a tabulated format, as well as a final total for the cart
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$totalCost = 0;
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");
?>
<html>
<head>
<title> Din kurv </title>
<script language="JavaScript">
function UpdateQty(item)
{
itemId = item.name;
newQty = item.options[item.selectedIndex].text;
document.location.href = 'cart.php?action=update_item&id='+itemId+'&qty='+newQty;
}
</script>
</head>
<body bgcolor="#ffffff">
<form action="checkout.php" name="frmCart" method="get">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="15%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8">
<b>Antal</b>
</font>
</td>
<td width="55%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8">
<b>Produkt</b>
</font>
</td>
<td width="20%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8">
<b>Stk. pris</b>
</font>
</td>
<td width="10%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8">
<b>Fjern?</b>
</font>
</td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
// Increment the total cost of all items
$totalCost += ($row["qty"] * $row["itemPrice"]);
$porto = "1000";
?>
<tr>
<td width="15%" height="25">
<font face="verdana" size="1" color="black">
<select name="<?php echo $row["itemId"]; ?>" onChange="UpdateQty(this)">
<?php
for($i = 1; $i <= 20; $i++)
{
echo "<option ";
if($row["qty"] == $i)
{
echo " SELECTED ";
}
echo ">" . $i . "</option>";
}
?>
</select>
</font>
</td>
<td width="55%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["itemName"]; ?>
</font>
</td>
<td width="20%" height="25">
<font face="verdana" size="1" color="black">
<?php echo number_format($row["itemPrice"], 2, ".", ","); ?> Kr.
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
<a href="cart.php?action=remove_item&id=<?php echo $row["itemId"]; ?>">Fjern</a>
</font>
</td>
</tr>
<?php
}
// Display the total
?>
<tr>
<td width="100%" colspan="4">
<hr size="1" color="#2f83f6" NOSHADE>
</td>
</tr>
<tr>
<td width="70%" colspan="2">
<font face="verdana" size="1" color="black">
<a href=checkout.php>Fuldfør handlen >></a>
<input type="submit" value="Send" name="B1">
</form>
</font>
</td>
<td width="30%" colspan="2">
<font face="verdana" size="2" color="black">
<b><br>
<table border="0" width="300" cellpadding="0" cellspacing="0">
<tr >
<td>
<b>Porto:</b><hr size="1" color="#2f83f6">
</td>
<td align="right">
<?php
if ($totalCost >= $porto) {
echo "0.00 Kr.";
$fri = "0";
}
else {
echo "56.00 Kr.";
$port = "56";}
?>
<hr size="1" color="#2f83f6">
</td>
</tr>
</table>
<br>
<table border="0" width="300" cellpadding="0" cellspacing="0" >
<tr>
<td>
<b>Total:</b>
</td>
<td align="right">
<?php echo number_format($totalCost + $fri + $port , 2, ".", ","); ?> Kr.</b>
</td>
</tr>
</table>
</font>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
?>
Db.php
<?php
//create table items
//(
//itemId int auto_increment not null,
//itemName varchar(50),
//itemDesc varchar(250),
//itemPrice decimal(4,2),
//primary key(itemId),
//unique id(itemId)
//);
//
//create table cart
//(
//cartId int auto_increment not null,
//cookieId varchar(50),
//itemId int,
//qty int,
//primary key(cartId),
//unique id(cartId)
//
//);
// This page contains the connection routine for the
// database as well as getting the ID of the cart, etc
$dbServer = "";
$dbUser = "";
$dbPass = "";
$dbName = "";
function ConnectToDb($server, $user, $pass, $database)
{
// Connect to the database and return
// true/false depending on whether or
// not a connection could be made.
$s = @mysql_connect($server, $user, $pass);
$d = @mysql_select_db($database, $s);
if(!$s || !$d)
return false;
else
return true;
}
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) * 30));
return session_id();
}
}
?>
Products.php
<!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></title>
<link type="text/css" rel="stylesheet" href="files/style.css"></head><body>
<div align="right">
<table border="0">
<tbody><tr>
<td bgcolor="#2f83f6"><a href=""
onclick="window.open('support.htm','mitvindue','height=480,width=690');return false;"
onmouseover="document.NAME.src='support_small.jpg'"
onmouseout="document.NAME.src='none.jpg'"><img name="NAME" src="none.jpg">
</a></td>
</tr>
</tbody></table>
</div>
<p align="right">
</p>
<p align="center">
<img src="cooltext51699685.jpg" border="0" height="66" width="536"></p>
<p align="right"><br>
</p>
<div class="topnav">
<a href="index.htm">Forside</a>
<a href="nyheder.htm">Nyheder</a>
<a href="produkter.htm">Produkter </a>
<a href="om_os.htm">Om DCM</a>
<a href="vi_søger.htm">Vi søger</a>
<a href="" onclick="window.open('kontakt.htm','mitvindue','height=600,width=690');return false;">
Kontakt </a>
</div>
<div class="main">
<h3 align="left"><font size="6"><center> P</font><font color="#2f83f6">rodukter</center></font> </h3>
<div style="border-top: 1px solid rgb(0, 102, 204); width: 602px; height: 1630px;">
<div style="margin: 0px; padding: 0px; width: 440px; float: left; height: 1417px;">
<div style="border-left: 0px solid rgb(0, 102, 204); margin: 0px; width: 602px; float: left; height: 1374px;">
<p> <?php
// This page will list all of the items
// from the items table. Each item will have
// a link to add it to the cart
include("db.php");
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from items order by itemName asc");
?>
<html>
<head>
<title>Produkter</title>
</head>
<body bgcolor="#ffffff">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="30%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8"><b> Produkter
</b></font></td>
<td width="10%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8"><b>Pris </b>
</font></td>
<td width="50%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8"><b>Beskrivelse
</b></font></td>
<td width="10%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8"><b>Tilføj </b>
</font></td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td width="30%" height="25">
<font face="verdana" size="1" color="#2F83F6">
<?php echo $row["itemName"]; ?>
</font></td>
<td width="10%" height="25">
<font face="verdana" size="1" color="#2F83F6">
<?php echo $row["itemPrice"]; ?> </font><font face="verdana" size="1" color="#2F83F6">DK </font><font face="verdana" size="1" color="black">
</font></td>
<td width="50%" height="25">
<font face="verdana" size="1" color="#2F83F6">
<?php echo $row["itemDesc"]; ?>
</font></td>
<td width="10%" height="25">
<font face="verdana" size="1" color="#2F83F6">
<a href="" onclick="window.open('cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1','mitvindue','height=500,width=690');return false;">Køb</a>
</font></td>
</tr>
<tr>
<td width="100%" colspan="4">
<hr size="1" color="#2F83F6" NOSHADE></td>
</tr>
<?php
}
?>
<tr>
<td width="100%" colspan="4">
<font face="verdana" size="1"></font></a><font face="verdana" size="1" color="black">
<a href="" onclick="window.open('cart.php','Din kurv','height=500,width=690');return false;">Se din kurv >></a>
</font></td>
</tr>
</table>
</body>
</html></p>
<p> </p>
<hr color="#0066cc" size="1">
<p><font color="#2f83f6"><b>Hvordan handler du:</b></font></p>
<p>Alle vores produkter kan købes på:</p>
<p><a href="http://www.mini-shoppen.dk/">www.mini-shoppen.dk </a>
</p></div>
<p style="padding: 5px; text-align: center;"> </p>
<p style="padding: 5px; text-align: center;"> </p>
<p style="padding: 5px; text-align: center;"> </p>
<p style="padding: 5px; text-align: center;"><br><br></p></div></div>
</div>
<div class="ctr">
<div class="endnav">
<p> </p></div>
<p>© 2006 - 2010 <b>D</b><font color="#0066CC">in</font> <b>C</b><font color="#0066CC">omputer</font>
<b>M</b><font color="#0066CC">ekaniker</font></p>
</div>
</body></html>
ver.php
<?php
$custname = $_GET["T1"];
$custmail = $_GET["T2"];
$custadr = $_GET["S1"];
$custby = $_GET["T3"];
$custpost = $_GET["T4"];
$custtele = $_GET["T5"];
$row = $_GET["bestil"];
$to = "kim@mini-shoppen.dk";
include("db.php");
global $dbServer, $dbUser, $dbPass, $dbName;
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '". GetCartId() . "' order by items.itemName asc");
$row = mysql_fetch_assoc($result);
// <tr> <td><?php echo $row["itemName"]; ?></td>
// <td><?php echo $row["qty"]; ?></td>
// <td align="right"><?php echo number_format($row["itemPrice"], 2, ".", ","); ?></td></tr></table>
$subject = "Handel - DCM";
$message = "Navn: $custname - Email: $custmail - Addresse: $custadr - By: $custby - Post nr: $custpost - Telefon: $custtele - <table width="600" border="0" bgcolor="#2F83F6"><tr><td width="500"><b>Navn</b></td><td align=right><b>Antal</b></td> <td align=right width="100"><b>Pris</b></td></tr><tr> <td>$row["itemName"]; </td> <td>echo $row["qty"]</td> <td align="right">echo number_format($row["itemPrice"], 2, ".", ","); ?></td></tr></table>";
$headers = "Tak for din handel";
mail($to, $subject, $message, $headers); //Sender mailen
echo "Tak for din handel";?>
Ver.php
<?php
$custname = $_GET["T1"];
$custmail = $_GET["T2"];
$custadr = $_GET["S1"];
$custby = $_GET["T3"];
$custpost = $_GET["T4"];
$custtele = $_GET["T5"];
$row = $_GET["bestil"];
$to = "kim@mini-shoppen.dk";
include("db.php");
global $dbServer, $dbUser, $dbPass, $dbName;
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '". GetCartId() . "' order by items.itemName asc");
$row = mysql_fetch_assoc($result);
// <tr> <td><?php echo $row["itemName"]; ?></td>
// <td><?php echo $row["qty"]; ?></td>
// <td align="right"><?php echo number_format($row["itemPrice"], 2, ".", ","); ?></td></tr></table>
$subject = "Handel - DCM";
$message = "Navn: $custname - Email: $custmail - Addresse: $custadr - By: $custby - Post nr: $custpost - Telefon: $custtele - <table width="600" border="0" bgcolor="#2F83F6"><tr><td width="500"><b>Navn</b></td><td align=right><b>Antal</b></td> <td align=right width="100"><b>Pris</b></td></tr><tr> <td>$row["itemName"]; </td> <td>echo $row["qty"]</td> <td align="right">echo number_format($row["itemPrice"], 2, ".", ","); ?></td></tr></table>";
$headers = "Tak for din handel";
mail($to, $subject, $message, $headers); //Sender mailen
echo "Tak for din handel";?>
Db information står i db.phpJeg har fundet et tutorial med en shopping cart, men i den er der ikke en checkout, så derfor har jeg prøvet at lave en selv. men uden held.... så derfor spørger jeg alle jer, om der er nogen der vil lave den for mig....
Jeg poster de sider jeg har, og så skal der bare laves færdig.
cart.php
<?php
include("db.php");
switch($_GET["action"])
{
case "add_item":
{
AddItem($_GET["id"], $_GET["qty"]);
ShowCart();
break;
}
case "update_item":
{
UpdateItem($_GET["id"], $_GET["qty"]);
ShowCart();
break;
}
case "remove_item":
{
RemoveItem($_GET["id"]);
ShowCart();
break;
}
default:
{
ShowCart();
}
}
function AddItem($itemId, $qty)
{
// Will check whether or not this item
// already exists in the cart table.
// If it does, the UpdateItem function
// will be called instead
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
// Check if this item already exists in the users cart table
$result = mysql_query("select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This item doesn't exist in the users cart,
// we will add it with an insert query
@mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)");
}
else
{
// This item already exists in the users cart,
// we will update it instead
UpdateItem($itemId, $qty);
}
}
function UpdateItem($itemId, $qty)
{
// Updates the quantity of an item in the users cart.
// If the qutnaity is zero, then RemoveItem will be
// called instead
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
if($qty == 0)
{
// Remove the item from the users cart
RemoveItem($itemId);
}
else
{
mysql_query("update cart set qty = $qty where cookieId = '" . GetCartId() . "' and itemId = $itemId");
}
}
function RemoveItem($itemId)
{
// Uses an SQL delete statement to remove an item from
// the users cart
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId");
}
function ShowCart()
{
// Gets each item from the cart table and display them in
// a tabulated format, as well as a final total for the cart
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$totalCost = 0;
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");
?>
<html>
<head>
<title> Din kurv </title>
<script language="JavaScript">
function UpdateQty(item)
{
itemId = item.name;
newQty = item.options[item.selectedIndex].text;
document.location.href = 'cart.php?action=update_item&id='+itemId+'&qty='+newQty;
}
</script>
</head>
<body bgcolor="#ffffff">
<form action="checkout.php" name="frmCart" method="get">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="15%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8">
<b>Antal</b>
</font>
</td>
<td width="55%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8">
<b>Produkt</b>
</font>
</td>
<td width="20%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8">
<b>Stk. pris</b>
</font>
</td>
<td width="10%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8">
<b>Fjern?</b>
</font>
</td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
// Increment the total cost of all items
$totalCost += ($row["qty"] * $row["itemPrice"]);
$porto = "1000";
?>
<tr>
<td width="15%" height="25">
<font face="verdana" size="1" color="black">
<select name="<?php echo $row["itemId"]; ?>" onChange="UpdateQty(this)">
<?php
for($i = 1; $i <= 20; $i++)
{
echo "<option ";
if($row["qty"] == $i)
{
echo " SELECTED ";
}
echo ">" . $i . "</option>";
}
?>
</select>
</font>
</td>
<td width="55%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["itemName"]; ?>
</font>
</td>
<td width="20%" height="25">
<font face="verdana" size="1" color="black">
<?php echo number_format($row["itemPrice"], 2, ".", ","); ?> Kr.
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
<a href="cart.php?action=remove_item&id=<?php echo $row["itemId"]; ?>">Fjern</a>
</font>
</td>
</tr>
<?php
}
// Display the total
?>
<tr>
<td width="100%" colspan="4">
<hr size="1" color="#2f83f6" NOSHADE>
</td>
</tr>
<tr>
<td width="70%" colspan="2">
<font face="verdana" size="1" color="black">
<a href=checkout.php>Fuldfør handlen >></a>
<input type="submit" value="Send" name="B1">
</form>
</font>
</td>
<td width="30%" colspan="2">
<font face="verdana" size="2" color="black">
<b><br>
<table border="0" width="300" cellpadding="0" cellspacing="0">
<tr >
<td>
<b>Porto:</b><hr size="1" color="#2f83f6">
</td>
<td align="right">
<?php
if ($totalCost >= $porto) {
echo "0.00 Kr.";
$fri = "0";
}
else {
echo "56.00 Kr.";
$port = "56";}
?>
<hr size="1" color="#2f83f6">
</td>
</tr>
</table>
<br>
<table border="0" width="300" cellpadding="0" cellspacing="0" >
<tr>
<td>
<b>Total:</b>
</td>
<td align="right">
<?php echo number_format($totalCost + $fri + $port , 2, ".", ","); ?> Kr.</b>
</td>
</tr>
</table>
</font>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
?>
Db.php
<?php
//create table items
//(
//itemId int auto_increment not null,
//itemName varchar(50),
//itemDesc varchar(250),
//itemPrice decimal(4,2),
//primary key(itemId),
//unique id(itemId)
//);
//
//create table cart
//(
//cartId int auto_increment not null,
//cookieId varchar(50),
//itemId int,
//qty int,
//primary key(cartId),
//unique id(cartId)
//
//);
// This page contains the connection routine for the
// database as well as getting the ID of the cart, etc
$dbServer = "l";
$dbUser = "";
$dbPass = "";
$dbName = "";
function ConnectToDb($server, $user, $pass, $database)
{
// Connect to the database and return
// true/false depending on whether or
// not a connection could be made.
$s = @mysql_connect($server, $user, $pass);
$d = @mysql_select_db($database, $s);
if(!$s || !$d)
return false;
else
return true;
}
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) * 30));
return session_id();
}
}
?>
Products.php
<!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></title>
<link type="text/css" rel="stylesheet" href="files/style.css"></head><body>
<div align="right">
<table border="0">
<tbody><tr>
<td bgcolor="#2f83f6"><a href=""
onclick="window.open('support.htm','mitvindue','height=480,width=690');return false;"
onmouseover="document.NAME.src='support_small.jpg'"
onmouseout="document.NAME.src='none.jpg'"><img name="NAME" src="none.jpg">
</a></td>
</tr>
</tbody></table>
</div>
<p align="right">
</p>
<p align="center">
<img src="cooltext51699685.jpg" border="0" height="66" width="536"></p>
<p align="right"><br>
</p>
<div class="topnav">
<a href="index.htm">Forside</a>
<a href="nyheder.htm">Nyheder</a>
<a href="produkter.htm">Produkter </a>
<a href="om_os.htm">Om DCM</a>
<a href="vi_søger.htm">Vi søger</a>
<a href="" onclick="window.open('kontakt.htm','mitvindue','height=600,width=690');return false;">
Kontakt </a>
</div>
<div class="main">
<h3 align="left"><font size="6"><center> P</font><font color="#2f83f6">rodukter</center></font> </h3>
<div style="border-top: 1px solid rgb(0, 102, 204); width: 602px; height: 1630px;">
<div style="margin: 0px; padding: 0px; width: 440px; float: left; height: 1417px;">
<div style="border-left: 0px solid rgb(0, 102, 204); margin: 0px; width: 602px; float: left; height: 1374px;">
<p> <?php
// This page will list all of the items
// from the items table. Each item will have
// a link to add it to the cart
include("db.php");
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from items order by itemName asc");
?>
<html>
<head>
<title>Produkter</title>
</head>
<body bgcolor="#ffffff">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="30%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8"><b> Produkter
</b></font></td>
<td width="10%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8"><b>Pris </b>
</font></td>
<td width="50%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8"><b>Beskrivelse
</b></font></td>
<td width="10%" height="25" bgcolor="#2F83F6">
<font face="verdana" size="1" color="#D8D8D8"><b>Tilføj </b>
</font></td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td width="30%" height="25">
<font face="verdana" size="1" color="#2F83F6">
<?php echo $row["itemName"]; ?>
</font></td>
<td width="10%" height="25">
<font face="verdana" size="1" color="#2F83F6">
<?php echo $row["itemPrice"]; ?> </font><font face="verdana" size="1" color="#2F83F6">DK </font><font face="verdana" size="1" color="black">
</font></td>
<td width="50%" height="25">
<font face="verdana" size="1" color="#2F83F6">
<?php echo $row["itemDesc"]; ?>
</font></td>
<td width="10%" height="25">
<font face="verdana" size="1" color="#2F83F6">
<a href="" onclick="window.open('cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1','mitvindue','height=500,width=690');return false;">Køb</a>
</font></td>
</tr>
<tr>
<td width="100%" colspan="4">
<hr size="1" color="#2F83F6" NOSHADE></td>
</tr>
<?php
}
?>
<tr>
<td width="100%" colspan="4">
<font face="verdana" size="1"></font></a><font face="verdana" size="1" color="black">
<a href="" onclick="window.open('cart.php','Din kurv','height=500,width=690');return false;">Se din kurv >></a>
</font></td>
</tr>
</table>
</body>
</html></p>
<p> </p>
<hr color="#0066cc" size="1">
<p><font color="#2f83f6"><b>Hvordan handler du:</b></font></p>
<p>Alle vores produkter kan købes på:</p>
<p><a href="http://www.mini-shoppen.dk/">www.mini-shoppen.dk </a>
</p></div>
<p style="padding: 5px; text-align: center;"> </p>
<p style="padding: 5px; text-align: center;"> </p>
<p style="padding: 5px; text-align: center;"> </p>
<p style="padding: 5px; text-align: center;"><br><br></p></div></div>
</div>
<div class="ctr">
<div class="endnav">
<p> </p></div>
<p>© 2006 - 2010 <b>D</b><font color="#0066CC">in</font> <b>C</b><font color="#0066CC">omputer</font>
<b>M</b><font color="#0066CC">ekaniker</font></p>
</div>
</body></html>
ver.php
<?php
$custname = $_GET["T1"];
$custmail = $_GET["T2"];
$custadr = $_GET["S1"];
$custby = $_GET["T3"];
$custpost = $_GET["T4"];
$custtele = $_GET["T5"];
$row = $_GET["bestil"];
$to = "kim@mini-shoppen.dk";
include("db.php");
global $dbServer, $dbUser, $dbPass, $dbName;
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '". GetCartId() . "' order by items.itemName asc");
$row = mysql_fetch_assoc($result);
// <tr> <td><?php echo $row["itemName"]; ?></td>
// <td><?php echo $row["qty"]; ?></td>
// <td align="right"><?php echo number_format($row["itemPrice"], 2, ".", ","); ?></td></tr></table>
$subject = "Handel - DCM";
$message = "Navn: $custname - Email: $custmail - Addresse: $custadr - By: $custby - Post nr: $custpost - Telefon: $custtele - <table width="600" border="0" bgcolor="#2F83F6"><tr><td width="500"><b>Navn</b></td><td align=right><b>Antal</b></td> <td align=right width="100"><b>Pris</b></td></tr><tr> <td>$row["itemName"]; </td> <td>echo $row["qty"]</td> <td align="right">echo number_format($row["itemPrice"], 2, ".", ","); ?></td></tr></table>";
$headers = "Tak for din handel";
mail($to, $subject, $message, $headers); //Sender mailen
echo "Tak for din handel";?>
checkout.php
<form name="bestil" action="ver.php" method="get">
<?php
include("db.php");
global $dbServer, $dbUser, $dbPass, $dbName;
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from cart inner join items on cart.itemId
= items.itemId where cart.cookieId = '". GetCartId() . "' order by
items.itemName asc");
?>
<html><body>
<?php
$row = mysql_fetch_assoc($result);
$numRows = mysql_num_rows($result);
if($numRows == 0)
{
echo "Din kurv er tom.";
}
else
echo "<br>";
{
do
{
?>
<table width="600" border="0" bgcolor="#2F83F6"><tr><td width="500"><b>Navn</b></td><td align=right><b>Antal</b></td>
<td align=right width="100"><b>Pris</b></td></tr>
<tr> <td><?php echo $row["itemName"]; ?></td>
<td><?php echo $row["qty"]; ?></td>
<td align="right"><?php echo number_format($row["itemPrice"], 2, ".", ","); ?></td></tr></table>
<?php
} while($row = mysql_fetch_assoc($result));
}
mysql_query("delete from cart where cart.cookieId = '". GetCartId() . "'");
?>
<br>
<table width="500">
<tr>
<td width="25%">Navn:</td>
<td width="75%"><input type="text" name="T1" size="20"></td>
</tr>
<tr>
<td height="24">Email:</td>
<td height="24"><input type="text" name="T2" size="20"></td>
</tr>
<tr>
<td>Adresse:</td>
<td><textarea rows="2" name="S1" cols="20"></textarea></td>
</tr>
<tr>
<td>By:</td>
<td><input type="text" name="T3" size="20"></td>
</tr>
<tr>
<td>Post nr:</td>
<td><input type="text" name="T4" size="20"></td>
</tr>
<tr>
<td>Telefon</td>
<td><input type="text" name="T5" size="20"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td> </td>
</tr>
<input type="submit" value=Bestil>
</table>
</form>
<p> </p>
Db information står i db.php
Indlæg senest redigeret d. 24.04.2007 08:33 af Bruger #11717