Hi ive got some code that i need helping with, basically i want to click on a box next to a product and then send it into the basket.
Below is the products.
<?include("conninfo.php")?>
<?php
session_start();
?>
<html>
<head>
<title>The Music Shop</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<div id="header"><h1><img src="Images/banner.jpg"</h1>
</div>
<div id = "top_nav">
<a href="index.html">Home</a><span class="invisible"> | </span>
<a href="register.php">Register</a><span class="invisible"> | </span>
<a href="account.php">Login</a><span class="invisible"> | </span>
<a href="products.php">Products</a><span class="invisible"> | </span>
<a href="search.php">Search</a><span class="invisible"> | </span>
<a href="cart.php">Shopping Basket|</a>
</div>
<?
$query="select * FROM products ";
$result=mysql_query($query) or die("Couldnt do it");?>
<?$numrows=mysql_num_rows($result);
if ($numrows>0)
{?>
<table border="1">
<?
while($r=mysql_fetch_array($result))
{?>
<form action="cart.php" method="post">
<tr>
<td><?echo $r['ProductID'];?></td>
<td><?echo $r["ProductPrice"];?></td>
<td><?echo $r["ProductName"];?></td>
<td><img src="images/<?echo $r["Preview"];?>" alt="Image"></td>
<td><input type="submit" value="Add to Basket"><td/>
</form>
</td>
</tr>
<?
}
?>
</table>
<?}
else
{
echo("Nothing Found.");
}
Which leads onto the cart.php
<?include("conninfo.php")?>
<?php
session_start();
?>
<html>
<head>
<title>The Music Shop</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<div id="header"><h1><img src="Images/banner.jpg"</h1>
</div>
<div id = "top_nav">
<a href="index.html">Home</a><span class="invisible"> | </span>
<a href="register.php">Register</a><span class="invisible"> | </span>
<a href="account.php">Login</a><span class="invisible"> | </span>
<a href="products.php">Products</a><span class="invisible"> | </span>
<a href="search.php">Search</a><span class="invisible"> | </span>
<a href="cart.php">Shopping Basket|</a>
</div>
<?
$id=$_POST['ProductID'];
$price=$_POST['ProductPrice'];
$name=$_POST['ProductName'];
$query = mysql_query("INSERT INTO basket(ProductID,ProductPrice,ProductName)
VALUES('$id','$price','$name'")or die("Couldnt");
?>
Go to Basket:
</body>
</html>
Whenever i click on a box to "buy" the product i get:
Notice: Undefined index: ProductID in d:\inetpub\wwwroot\SimonJenkins\Assignment\cart.php on line 26
Notice: Undefined index: ProductPrice in d:\inetpub\wwwroot\SimonJenkins\Assignment\cart.php on line 27
Notice: Undefined index: ProductName in d:\inetpub\wwwroot\SimonJenkins\Assignment\cart.php on line 28
Couldnt