0

hello guys,i am having a problem when i want to post some variables using multiple forms.please i need some help.

the first file contains the following:

<?php
if(isset($_GET["submit"]) && $_GET["submit"])
{
 $qty1=$_POST["qty1"];
 $qty2=$_POST["qty2"];
 $qty3=$_POST["qty3"];
 $qty4=$_POST["qty4"];
 $qty5=$_POST["qty5"];

}
else
{
?>

     <table border="3" align="center" width="90%" >
        <tr><BR><BR>
            <th bgcolor="#ECD672" align="center">¸éäïò Êáõóßìïõ</th>
            <th bgcolor="#ECD672" align="center" >ÏêôÜíéá</th>
            <th bgcolor="#ECD672" align="center">ÔéìÞ</th>
            <th bgcolor="#ECD672" align="center" width="20%">Ðïóüôçôá/Lt</th>
        </tr>
<?php
$sql = "SELECT * FROM tbl_product WHERE prd_category=1";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
?>
        <form action="purchase1.php" name="purchase_form" method="post" onSubmit="return checkContent();">
        <tr>
            <td align="center"><?php echo $row["prd_name"];?></td>
            <td align="center"><?php echo $row["prd_octane"];?></td>
            <td align="center"><?php echo $row["prd_price"];?></td>
            <td align="center">
                <select name="qty1">
                            <option value="qty1">0</option>
                            <option value="qty2">200</option>
                            <option value="qty3">400</option>
                            <option value="qty4">600</option>
                            <option value="qty5">1000</option>
                            </select>
            </td>
        </tr></form>
<?php
}
?>

<?php
$sql = "SELECT * FROM tbl_product WHERE prd_category=2";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
?>
           <form action="purchase1.php" name="purchase_form" method="post" onSubmit="return checkContent();">
           <tr>
            <td><?php echo $row["prd_name"]; ?></td>
            <td><?php echo $row["prd_octane"]; ?></td>
            <td><?php echo $row["prd_price"]; ?></td>
            <td align="center">
                <select name="qty2">
                            <option value="qty1">0</option>
                            <option value="qty2">200</option>
                            <option value="qty3">400</option>
                            <option value="qty4">600</option>
                            <option value="qty5">1000</option>
                            </select>
            </td>
        </tr></form>
<?php
}
?>

<?php
$sql = "SELECT * FROM tbl_product WHERE prd_category=3";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
?>
           <form action="purchase1.php" method="post" onSubmit="return checkContent();">
           <tr>
            <td><?php echo $row["prd_name"]; ?></td>
            <td><?php echo $row["prd_octane"]; ?></td>
            <td><?php echo $row["prd_price"]; ?></td>
            <td align="center">
                <select name="qty3">
                            <option value="qty1">0</option>
                            <option value="qty2">200</option>
                            <option value="qty3">400</option>
                            <option value="qty4">600</option>
                            <option value="qty5">1000</option>
                            </select>
            </td>
        </tr></form>
<?php
}
?>

<?php
$sql = "SELECT * FROM tbl_product WHERE prd_category=4";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
?>
           <form action="purchase1.php" name="purchase_form" method="post" onSubmit="return checkContent();">
           <tr>
            <td><?php echo $row["prd_name"]; ?></td>
            <td><?php echo $row["prd_octane"]; ?></td>
            <td><?php echo $row["prd_price"]; ?></td>
            <td align="center">
                <select name="qty4">
                            <option value="qty1">0</option>
                            <option value="qty2">200</option>
                            <option value="qty3">400</option>
                            <option value="qty4">600</option>
                            <option value="qty5">1000</option>
                            </select>
            </td>
        </tr>
             </form>
<?php
}
?>

<?php
$sql = "SELECT * FROM tbl_product WHERE prd_category=5";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
?>
           <form action="purchase1.php" name="purchase_form" method="post" onSubmit="return checkContent();">
           <tr>
            <td><?php echo $row["prd_name"]; ?></td>
            <td><?php echo $row["prd_octane"]; ?></td>
            <td><?php echo $row["prd_price"]; ?></td>
            <td align="center">
                <select name="qty5">
                            <option value="qty1">0</option>
                            <option value="qty2">200</option>
                            <option value="qty3">400</option>
                            <option value="qty4">600</option>
                            <option value="qty5">1000</option>
                            </select>
            </td>
          </tr></form>
<?php
}
?>
         </table>
                  <BR><BR>
        <form action="purchase1.php?submit=OK" name="purchase_form" method="POST">  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input class="nav-subs" type="image" src="../images/go.gif" value="submit" />
        </form>
        </div>

and in the second file i want to see if this variable has it's value  

<?php include("../common/config.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<body>
<?php
echo "$qty1";
?>
</body>
</html>

Edited by mike_2000_17: Fixed formatting

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by urtrivedi
0

You can not submit multiple form at the same time. for that you need to use hidden elements. So before submitting form, you need to fill these hidden elements with required data from other forms.

Edited by urtrivedi: n/a

0

is any way to use multiple form submit in a single form using the same code,or what should i change?

thans for your help

0

for that you have to bring all element in one form. here you action page is purchase1.php, you should merge all forms into one which are calling purchase1.php.

You can use separate form if you want to call script other than purchase1.php.

0

could you please show me an example code or make a small change at mine, beacause i can't understand exactly what you mean

0

You are trying to manage multiple record at the same time. Do not use such logic.
instead pass categoryid at a time. and manage one record at a time. I could not explain here what ever you expect because you are going in the totally wrong direction.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.