garevn
05-23-2011, 11:31 PM
Atm i have almost complete the insert page just 2 things left and need some help.
my insert page looks like
<?php
session_start();
$productid=$_SESSION['productid'] ;
$pricetotal=$_SESSION['pricetotal'] ;
$price=$_SESSION['price'] ;
$cartTotal=$_SESSION['cartTotal'] ;
$quantity=$_SESSION['quantity'] ;
$MM_Username = $_SESSION['MM_Username'];
$quantity=$_SESSION['quantity'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mypc", $con);
$sql1="INSERT INTO sales(address, paymethod, creditcard,cardtype,username,cartTotal,phone) VALUES
('$_POST[address]','$_POST[RadioGroup1]','$_POST[pass]','$_POST[type]','$MM_Username','$cartTotal','$_POST[phone]')";
if (!mysql_query($sql1,$con))
{
die('Error: ' . mysql_error());
}
$sql2="INSERT INTO orders(unitprice,pricetotal,quantity,productid ) VALUES
('$price','$pricetotal','$quantity','$productid')";
if (!mysql_query($sql2,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
1--> Atm sql2 insert only the last product's id at the table.
I need to insert all products chosen by the user.
If for example made 10 selections then i insert all 10 rows into mysql
2--> I want to display a message to him like "the processing was successfull" but in the same page. Atm when i insert the products i see a blank page or a message which i removed.
my insert page looks like
<?php
session_start();
$productid=$_SESSION['productid'] ;
$pricetotal=$_SESSION['pricetotal'] ;
$price=$_SESSION['price'] ;
$cartTotal=$_SESSION['cartTotal'] ;
$quantity=$_SESSION['quantity'] ;
$MM_Username = $_SESSION['MM_Username'];
$quantity=$_SESSION['quantity'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mypc", $con);
$sql1="INSERT INTO sales(address, paymethod, creditcard,cardtype,username,cartTotal,phone) VALUES
('$_POST[address]','$_POST[RadioGroup1]','$_POST[pass]','$_POST[type]','$MM_Username','$cartTotal','$_POST[phone]')";
if (!mysql_query($sql1,$con))
{
die('Error: ' . mysql_error());
}
$sql2="INSERT INTO orders(unitprice,pricetotal,quantity,productid ) VALUES
('$price','$pricetotal','$quantity','$productid')";
if (!mysql_query($sql2,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
1--> Atm sql2 insert only the last product's id at the table.
I need to insert all products chosen by the user.
If for example made 10 selections then i insert all 10 rows into mysql
2--> I want to display a message to him like "the processing was successfull" but in the same page. Atm when i insert the products i see a blank page or a message which i removed.