hi friends
i have a form with 3 fields .all data are fetching from data base now i have 1 problem that when i click on submit the page show warning error of undifined index.
i paste my code here kindly help me i m in a gr8 trouble..i also attach these 2 files if any 1 having problm to understand..guys plz help me out.
thanks.
--------------------------------code----------------------------
This is one file name : bkpint_tariff.php
<?php
require ('sql_connect.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>International Tariff</title>
</head>
<script type="text/javascript" src="jquery-1.2.3.min.js"></script>
<script>
function show_weights(){
var shipment_id;
shipment_id = jQuery('#shipment_id').val();
jQuery('#shipment_id').attr('disabled', 'disabled');
$.ajax({
type: "POST",
url: "ajax_show_weights.php",
data: "find=weight&shipment_id="+shipment_id,
success: function(html){
$("#weight").append(html);
}
});
}
</script>
<br></br>
<div style="float:right; width:250px; padding-right: 50px;">
<a href="#"><img src="http://ocs.com.pk/newweb/wp-content/themes/ocs/images/logo.png">
</a></div>
<center><h1>International Tariff</h1></center>
<table width="385" height="200" style=" border:2px solid silver" cellpadding="6px" cellspacing="0px" align="center" border="0">
<form method="POST" action="bkpint_tariff.php">
<tr>
<td colspan="3" style="background:#0066FF; color:#FFFFFF; fontsize:50px">International Tariff</td></tr>
<tr>
<td>Selection Of countries :</td>
<td>
<select name="country_id">
<option value="">--SELECT--</option>
<?php
$q= "select * from country";
$r=my_query ($q);
while ($row = mysql_fetch_array($r)){
?>
<option value ="<?php echo $row['id'];?>"> <?php echo $row['countries_name']; ?>
</option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Selection of Shipments</td>
<td>
<select name="shipment_id" id="shipment_id" onChange="show_weights();">
<option value="">--SELECT--</option>
<?php
$q = "Select * from shipment order by id desc";
$res = my_query($q);
$cnt = mysql_num_rows($res);
while($row = mysql_fetch_assoc($res)){
?>
<option value="<?php echo $row['id'];?>"><?php echo $row['shipment_name'];?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td> Selection of Weight </td>
<td id="show_weights"> </td>
</tr>
<div class="form-items" id="country">
</div>
<div class="form-items" id="shipment">
</div>
<div class="form-items" id="weight">
</div>
<tr>
<td> <input type="submit" value="Calculate Rate" name="submit"> </td>
</tr>
<br>
</br>
</form>
<table width="385" style=" border:2px solid silver" cellpadding="6px" cellspacing="0px" align="center" border="0">
<tr>
<td>
<?php
if(isset($_POST['submit']))
{
$country_id = $_POST['country_id'];
}
?>
<?php
//This is PHP validation
if(empty($weight) || empty($country_id) || empty($shipment_id)){
?><center><?php echo "Please filled all the fields first.";?></center>
<?php
}
else{
$s = "select r.*
from rates r, zones_countries_mapping zcm
where
r.shipment_id=$shipment_id
AND
r.weight_id = $weight_id
AND
zcm.zone_name = r.zone_name
AND
zcm.country_id = $country_id";
$result = mysql_query($s);
$row = mysql_fetch_assoc($result);
//print_r($row);
?>
</td>
</tr>
<tr style="background:#00CFFF; color:black;">
<td><center><strong><font size="3"> Rate : </font></strong>
<?php
$val = (float) $row['value'] * 89 * 1.16 * 1.10;
echo "<strong>"."Rs"."."." ".$val;
?>
</center>
</td>
</tr>
<?php
}
?>
</table>
</table>
--------------------------------code 2nd file---------------------------------------------------------------------
This file name is "ajax_show_weight.php"
<?php require('sql_connect.php'); ?>
<?php
$shipment_id = $_POST['shipment_id'];
if(isset($_POST['shipment_id'])){$shipment_id = $_POST['shipment_id'];} else{$shipment_id = NULL;}
if (isset($_POST['find'])) { $find = $_POST['find'];} else{$find = NULL;}
if($find == 'weight'){
?>
<select class="select" name="weight_id" id="weight_id">
<option value="">--SELECT--</option>
<?php
$q = "Select * from weights wgt where wgt.shipment_id = $shipment_id order by wgt.id";
$res = my_query($q);
while($row = mysql_fetch_assoc($res)){
?>
<option value="<?php echo $row['id'];?>"><?php echo $row['value'];?></option>
<?php
}
?>
</select>
<?php
}
?>