**Can anybody help me??? I'm newbie in php, I'm trying to make this code as one below.But it always gives me an error. Any help would greatly appreciated **

my table name is trans
![Fields[1]

*

    *$id = $_POST['id'];
        if(isset($_REQUEST['command']) && $_REQUEST['command'] == 'update'){
        $name =  $_POST['name'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $location = $_POST['location'];
        $pid=$_SESSION['cart'][$i]['productid'];
        $q=$_SESSION['cart'][$i]['qty'];
        $price=get_price($pid);
    {
    die("<script>alert('order fail! Quantity Must not be greater than the stocks!!'); location.replace('index.php')</script>");
        }
    $total = number_format($price * $qty);*
    echo "Order was Successfully Send!!
    <br><br>
    Amount to paid: $price<br>
    Ordered: $qty<br>
    Customer: $name<br>
    Email: $email<br>
    Contact: $phone<br>
    Location: $location<br><br>
    Payment Key: $key
    <br><br><a href='index.php'></a>";
            $query("insert into feedback values(('key','name','email','phone','location','pid','qua','price')
            values(('key','$name','email','$phone','$location','$pid','$q','$price')");
            $result = mysql_query($query) or die(mysql_error());

    //$content = "Name:" . $_POST['name'] ."<br>Email:". $_POST['email'] ."<br>Phone:". $_POST['phone'] .
    //"<br>Location:". $_POST['location'] ."<br>Price:". $_POST['price'] .
    //"<br>Quantity:". $_POST['quantity'];
    //mail($to , $subject, $content, "From: $from \n" ."MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1");

    }
    else{
        echo "<script>alert('order fail! message was not complete!')</script>";
        echo "<script>location.replace('index.php')</script>";
    }
    //echo "<script>location.replace('index.php')</script>";
    ?>

*
**Working codes**
----------------------------------------------------------------------------------

if(($_POST['name']!="")&&($_POST['email']!="")&&($_POST['phone']!="")&&($_POST['quantity']!="")){


    $subject = 'inquery from my shop site !!!';
    $from = $_POST['email'];
    $name =  $_POST['name'];
    $email = $_POST['email'];
    $contact = $_POST['phone'];
    $location = $_POST['country'];
    $prodname = $_POST['prodname'];
    $price = $_POST['price'];
    $qty = (int)$_POST['quantity'];
    $stock = (int)$_POST['stock'];
    $productid = $_POST['prid'];
if($qty > $stock || $qty == 0){ 

die("<script>alert('order fail! Quantity Must not be greater than the stocks!!'); location.replace('index.php')</script>");
    }

$total = number_format($price * $qty);


echo "Order was Successfully Send!!
<br><br>
Product name: $prodname<br>
Amount to paid: P$price <br><br>
Customer: $name<br>
Ordered: $qty<br>
Contact: $contact<br>
Email: $email<br>
Location: $location<br><br>

Payment Key: $key
<br><br><a href='index.php'></a>";


$query = "insert into transaction_tbl(`key`,`fname`,`email`,`contact`,`location`,`productid`,`productname`,`quantity`,`price`,`stock`,`orderstat`) 
    values('$key','$name','$email','$contact','$location','$productid','$prodname','$qty','$price','$stock','pending')";
$result = mysql_query($query) or die(mysql_error());

//$content = "Name:" . $_POST['name'] ."<br>Email:". $_POST['email'] ."<br>Phone:". $_POST['phone'] .
//"<br>Country:". $_POST['country'] ."<br>Product name:". $_POST['prodname'] ."<br>Price:". $_POST['price'] .
//"<br>Quantity:". $_POST['quantity'];
//mail($to , $subject, $content, "From: $from \n" ."MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1");



}
else{
    echo "<script>alert('order fail! message was not complete!')</script>";
    echo "<script>location.replace('index.php')</script>";
}
//echo "<script>location.replace('index.php')</script>";



?>


  [1]: http://i.stack.imgur.com/Ux8EU.png

But it always gives me an error.

What error message?

it says order fail message error was not complete.

Yes, the die is always executed. I think there is an if missing.

thank you..where can I insert the missing >if? thanks again.

Depends on what you want. Compare with the second snippet, it's there, although I don't know if that's what you want.

thanks sir I try to analyze it again thank you so much for your replies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.