Thanks
I have worked a little bit on cleaning up the page.
My transaction information still doesn't pull through to my confirmation page.
Think I have put a mind block on myself, and can't see how it should work.
Sorry for posting so much code on one page, but I don't know where my problem is....
any one?
Transaction Page:
<?php
$picpath = $POST['picpath'];
$prod_code_name = $POST['prod_code_name'];
$proddecript = $POST['proddescript'];
$quantity = $POST['quantity'];
$prodcost = $POST['prodcost'] * "$quantity";
$total = $POST['total'];
?>
<?php
$conn= mysql_connect( "localhost", "user", "pass" );
$rs = mysql_select_db( "my_db", $conn);
$rs = mysql_query("Select * from product");
echo ("<table width='100%' border=2><tr><th>Picture:</th><th>Product Code/Name:</th><th>Description:</th><th>Price:</th><th>Quantity:</th>");
while ($row = mysql_fetch_array($rs))
{
echo ("<tr>");
echo ("<td><img src=\"$row[picpath]\" width=\"45\" height=\"45\"></td><td>$row[prod_code_name]</td><td>$row[proddescript]</td><td>$row[prodcost]</td><td><form method=\"post\" action=\"confirm.php\">
<select id=\"quantity\" name=\"$row[quantity]\" size=\"1\">
<option value=\"0\">Select Quantity</option>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
<option value=\"6\">6</option>
<option value=\"7\">7</option>
<option value=\"8\">8</option>
<option value=\"9\">9</option>
<option value=\"10\">10</option>
</select></td>");
echo ("</tr>");
}
echo ("<input name=\"btnTest\" type=\"submit\" value=\"Submit\">");
echo ("</form>");
echo ("</table>");
?>
My Confirmation Page:
<?php
$total = $_POST['total'];
echo "$picpath$prod_code_name$proddecript$prodcost$total*$quantity";
if ($prod_code_name and $prodcost and $total and $quantity )
{
$conn= @mysql_connect( "localhost", "user", "pass" )
or die( "Could not Connect to Database" );
$rs = @mysql_select_db( "my_db", $conn )
or die( "Could not Select Database" );
$sql = "insert into transact (custid, prod_code_name, total, quantity)
values ($custid, '$prod_code_name', $total, $quantity)";
$rs = mysql_query( $sql, $conn )
or die ("Could not execute query");
if($rs)
{
$rs = "Transaction information has been added successfully for $total $custname $custsurname $custid" ;
}
else
mysql_close($conn);
{
echo ("Could not Add Transaction.");
}}
?>
<?php
$total=0;
if(isset($POST['btnTest']))
{
$picpath = $POST['picpath'];
$prod_code_name = $POST['prod_code_name'];
$proddecript = $POST['proddescript'];
$quantity = $POST['quantity'];
$prodcost = $POST['prodcost'] * $s;
$total+=$quantity;
}
{
echo("<table border=\"1\">");
echo("<tr>");
echo("<td bgcolor=\"#b5c7dc\">Products Code-Name</td>");
echo("<td bgcolor=\"#b5c7dc\">Image</td>");
echo("<td bgcolor=\"#b5c7dc\">Description</td>");
echo("<td bgcolor=\"#b5c7dc\">Quantity</td>");
echo("<td bgcolor=\"#b5c7dc\">Price</td>");
echo("<td bgcolor=\"#b5c7dc\">Total Price</td>");
echo("</tr>");
echo("<tr>");
echo("<td>".$POST['prod_code_name']."</td>");
echo("<td>".$POST['picpath']."</td>");
echo("<td>".$POST['proddescript']."</td>");
echo("<td>".$POST['quantity']."</td>");
echo("<td>".$POST['prodcost']."</td>");
echo("<td>".$POST['total']."</td>");
echo("</tr>");
echo("</table>");
}
?>
<?php
$self = $SERVER['php_self'];
$custname = $POST['custname'];
$custsurname = $POST['custsurname'];
$custpass = $POST['custpass'];
$custemail = $POST['custemail'];
$custtel = $POST['custtel'];
$cardtype = $POST['cardtype'];
$cardnum = $POST['cardnum'];
$expdate = $POST['expdate'];
$cvv = $POST['cvv'];
$total = $_POST['total'];
?>
<?php
echo"$custname$custsurname$custpass$custemail$custtel$cardtype$cardnum$expdate$cvv";
if ($custname and $custsurname and $custpass and $custemail and $custtel and $cardtype and $cardnum and $expdate and $cvv and $total)
{
$conn= @mysql_connect( "localhost", "root", "triadpass" )
or die( "Could not Connect to Database" );
$rs = @mysql_select_db( "ecommerce", $conn )
or die( "Could not Select Database" );
$sql = "insert into customer (custname, custsurname, custpass, custemail, custtel, cardtype, cardnum, expdate, cvv, total)
values ('$custname', '$custsurname', '$custpass', '$custemail', $custtel, '$cardtype', '$cardnum', '$expdate', $cvv , $total)";
$rs = mysql_query( $sql, $conn )
or die ("Could not execute query");
if($rs)
{
$rs = "Customer information has been added successfully for $custname $custsurname $custid" ;
}
else
{
echo ("Could not Add Customer.");
}}
?>
<div align="center">
<script type="text/javascript">
function check(form)
{
var jserror="";
if (form.custname.value=="")
jserror+="Please enter the Card Holder Name!\r\n";
if (form.custsurname.value=="")
jserror+="Please enter the Card Holder Surname!\r\n";
if (form.custpass.value=="")
jserror+="Please enter a Password!\r\n";
if (form.custemail.value.indexOf("@")==-1 || form.custemail.value.indexOf(".")==-1)
jserror+="Please enter a valid Email!\r\n";
if (form.cardtype.value=="")
jserror+="Please confirm Type of Credit Card!\r\n";
if (form.cardnum.value=="")
jserror+="Card Number must be at least 10 digits!\r\n";
if (form.expdate.value.indexOf("/")==-1)
jserror+="Please enter Card Expiry Date in correct format mm/yy!\r\n";
if (form.cvv.value== "")
jserror+="Invalid Validation Number, must be 3 digits!\r\n";
if (form.custtel.value=="")
jserror+="Please confirm Contact Number!\r\n";
if (jserror)
{
alert(jserror);
return false;
}
}
</script>
</div>
<form action="<?php echo ( $self ); ?>" method="post" onSubmit="return check(this);">
<div align="center">
<table width="37%" border="1">
<tr>
<td width="52%" height="31"><div align="right">Name :</div></td>
<td width="48%">
<div align="center">
<input type="text" name="custname" size="19">
<tr>
<td height="29"><div align="right">Surname :
</div></td>
<td>
<div align="center">
<input type="text" name="custsurname" size="19">
</div></td></tr>
<tr>
<td height="35"><div align="right">Password :
</div></td>
<td>
<div align="center">
<input type="text" name="custpass" size="19">
</div></td></tr>
<tr>
<td height="29"><div align="right">E-Mail:</div></td>
<td>
<div align="center">
<input type="text" name="custemail" size="19">
</div></td></tr>
<tr>
<td height="29"><div align="right">Contact Number:</div></td>
<td>
<div align="center">
<input type="text" name="custtel" size="19">
</div></td></tr>
<tr>
<td height="26"><div align="right">Card Number:</div></td>
<td>
<div align="center">
<input type="text" name="cardnum" size="19">
</div></td></tr>
<tr>
<td height="30"><div align="right">Card Type:</div></td>
<td>
<div align="center">
<select name="cardtype" id="select">
<option value="">Select Type Card</option>
<option value="visa">Visa</option>
<option value="mastercard">MasterCard</option>
<option value="americanexpress">American Express</option>
<option value="dinersclub">Diners Club</option>
</select>
</div></td></tr>
<tr>
<td height="26"><div align="right">Expiry Date:</div></td>
<td>
<div align="center">
<input type="text" name="expdate" size="19">
</div></td></tr>
<tr>
<td height="29"><div align="right">CVV / Validation Code:</div>
</td>
<td>
<div align="center">
<input type="text" name="cvv" size="19">
</div>
</td>
</tr>
<tr bordercolor="#000000">
<td><div align="right"><strong>Total Amount :</strong></div>
</td>
<td>R
<input name="total" type="text" value="<?php echo $total ?>" size="15" readonly="true">
</td>
</tr>
</table>
<br>
</div>
<p align="center">
<input type="submit" name="submit" value="Submit">
</p>
</form>