<?php
include_once("connectDB.php");
if ($_SESSION["loggedin"] != "true")
        header("Location : member_login.php");

$aname = $_SESSION["aname"] ;
$aid = $_SESSION["aid"];

$result = mysql_query("select * from member where m_ID = $aid");
$row =mysql_fetch_assoc($result);
$ticketid = $_REQUEST["ticketid"];
// Use this var to check to see if this ID exists, if yes then get the product 
$result = mysql_query("select * from ticket where ticketID = $ticketid ");

    // get all the product details
    while($row = mysql_fetch_assoc($result))
    { 
         $from = $row["ticketFrom"];
         $to = $row["ticketTo"];
         $date = $row["ticketDate"];
         $time = $row["ticketTime"];
         $type = $row["ticketType"];
         $price = $row["ticketPrice"];
    }    

        if(isset($_POST["book"]))
    {   
            $trip = $_POST["trip"];
            $return = $_POST["return"];
            $adult = $_POST["adults"];
            $children = $_POST["children"]; 
            $infant = $_POST["infants"]; 

        mysql_query("insert into booking (m_ID,bookFrom,bookTo,bookDepart,bookTime,bookClass,bookPrice,bookType,bookReturn,bookAdults,bookChildren,bookInfants)
        values ('$aid','$from','$to','$date','$time','$type','$price','$trip','$adult','$return','$adult','$children','$infant')");
?>
<script type ="text/javascript">
    alert("Product Have been Add to Cart");
</script>
<?php
}
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Store Homepage</title>
<link rel = stylesheet href="style/code1.css" type="text/css">
</head>
<body>
<div align="center" id="mainWrapper">
 <?php include_once("member_header.php")?>

 <div id="pageContent">

<table align="center" width="668px" border="1">  
<tr>
    <td rowspan="5"><align="center" width="300px" height="500px">
    <table align="left" width="500px" height="500px" border="1">
    <tr>
    <td colspan="2" align="center"><b>Return :</b><input type="radio"name="trip"value="return"checked required="required">
    </td>
    <td colspan="2" align="center"><b>One Way :</b><input type="radio"name="trip"value="oneway" required="required">
    </td>
    </tr>
    <tr>
    <td colspan="2" align="center"><b>From :</b><select name="origin">
                                                      <option value="<?php echo $from; ?>"><?php echo $from; ?></option>
                                                </select>
    </td>
    <td colspan="2" align="center"><b>Destination :</b><select name="destination">
                                                      <option value="<?php echo $to; ?>"><?php echo $to; ?></option>
                                                       </select>
    </td>
    </tr>

    <tr>
    <td colspan ="2" align="center"><b>Depart :</b><input type="date"name="return"size="20" value="<?php echo $date; ?>">
    </td>
    <td colspan = "2" align="center"><b>Return :</b><input type="date"name="return"size="20"required="required"/>
    </td>
    </tr>

    <tr>
    <td colspan="2" align="center"><b>Time :</b><input type="time"value="<?php echo $time; ?>"/>
    </td>
    <td colspan="2" align="center"><b>Type:<select name="type">
                                                <option value="<?php echo $type; ?>"><?php echo $type; ?></option>
                                           </select>
    </td>
    </tr>

    <tr>
    <td colspan="2" align="center"><b>Adults :</b>
                   <select name="adults" required="required">
                            <option value="0">0</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>
                   </select>
    </td>

    <td colspan ="2" align="center"><b>Children :</b>
                    <select name="children" required="required">
                            <option value="0">0</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>
                    </select>
    </td>
    <tr>
    <td colspan="3" align="center"><b>Infants :</b>
                    <select name="infants" required="required">
                            <option value="0">0</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>
                    </select>
    </td>
    </tr>
    </table>
    </td>

</tr>
<tr>
    <td align="center">Price: RM<?php echo $price; ?>
    <br><hr style="color:grey;">Adult Price: RM<?php echo $price; ?>
    <br><hr style="color:grey;">Children Price: RM<?php echo $price/2 ?>
    <br><hr style="color:grey;">Infants Price: RM<?php echo $price/2 ?>

</tr>

<form name="addcart" method="post" action="">
<tr>
    <br>
    <td colspan="2" rowspan="7" align="center"><input type="submit" name="book" value="Book"><br></td>
</tr>
</form>
</table></div>

<?php include_once("member_footer.php")?>

</div> 
</body>
</html>

Can you please repost this, and place an "description" above each file source what it is used for? I would love to help you, but atleast show some effort.

<?php
include_once("connectDB.php");
if ($_SESSION["loggedin"] != "true")
header("Location : memberLogin.php");

$aname = $_SESSION["aname"] ;
$aid = $_SESSION["aid"];
$result = mysql_query("select * from member where m_ID = $aid");
$row =mysql_fetch_assoc($result);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Store Homepage</title>
<link rel = stylesheet href="style/code1.css" type="text/css">
<script type="text/javascript">
function confirmation()
    {
var answer = confirm("Do you want to book this ticket?");
if(answer ==false)
            return false;
        else
        return true;
    }
</script>
</head>
<body>
<div align="center" id="mainWrapper">
 <?php include_once("memberHeader.php")?>
 <div id="pageContent">
  <form name="book" method="get" action="test.php">
  <table border="0" width="650px" align="center" style="border-color:black;">
<tr>
                <td colspan="7" style="font-family:Vivaldi; font-size:25pt; font-weight:bold; color:#565051;">Tickets Available</td>
        </tr>
    <tr>
        <td align="center"><b>From</b></td>
        <td align="center"><b>To</b></td>
        <td align="center"><b>Date</b></td>
        <td align="center"><b>Time</b></td>
        <td align="center"><b>Type</b></td>
        <td align="center"><b>Price</b></td>
        <td></td>
    </tr>
                <tr>
            <td colspan="7"><hr noshade size=3></td>
        </tr>
    <?php
            $result = mysql_query("select * from ticket ORDER BY ticketID DESC");
            if(mysql_num_rows($result) == 0)
            {
        ?>
                <tr>
                    <td colspan="6">No Tickets Updated</td>
                </tr>
        <?php
            }
            else
            while($row = mysql_fetch_assoc($result))
            {
    ?>
    <tr>
        <td align="center"><input type="text" size="30" name="from"><?php echo $row["ticketFrom"];?></td>
        <td align="center"><input type="text" size="30" name="to"><?php echo $row["ticketTo"];?></td>
        <td align="center"><input type="text" size="30" name="date"><?php echo $row["ticketDate"];?></td>
        <td align="center"><input type="text" size="30" name="time"><?php echo $row["ticketTime"]?></td>
        <td align="center"><input type="text" size="30" name="type"><?php echo $row["ticketType"]?></td>
        <td align="center"><input type="text" size="30" name="price">RM<?php echo $row["ticketPrice"]?></td>
        <td align="center" ><input type="submit" name="book" value="Book" style="font-size:14;">
    </tr>
            <tr>
            <td colspan="7"><hr noshade size=3></td>
        </tr>
        <?php
    }
    ?>  
</table>
 </div>
<?php include_once("memberFooter.php")?>
</div> 
</body>
</html>
?>

Is that what u wanted ? It woulfd so helpful if u manage to solve it. Its a online flight booking system.

See on my first post . I couldnt $_POST. I got error in line 28,29,30,3,31,32.

Notice: Undefined index: trip in C:\xamppp\htdocs\OFB\test.php on line 28

Notice: Undefined index: return in C:\xamppp\htdocs\OFB\test.php on line 29

Notice: Undefined index: adults in C:\xamppp\htdocs\OFB\test.php on line 30

Notice: Undefined index: children in C:\xamppp\htdocs\OFB\test.php on line 31

Notice: Undefined index: infants in C:\xamppp\htdocs\OFB\test.php on line 32

Your form and submit button appears to have the same name. In your first snippet there is no form tag.

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.