Problem with sessions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Could someone help with this code? It is a search and delete program. I'm
executing bunch of code within if-else statement. After searching the
records in else block the code is redirecting to if block. I'm not able
delete the records in else block. How do avoid the control move to if block?


<?php
session_start();
require_once('connection.php');
$_SESSION['voucher_value'] =  $_POST['voucher_to'];
if(!($_SESSION['voucher_value'] == b1) )
{
$tbl_name = "voucher";
$kodaikanal = "Resident Scientist <br /> IIA, Kodaikanal <br /> Observatory
<br /> KODAIKANAL - 624 103";
$hosakote = "Scientist in-charge <br /> CREST Campus <br /> HOSAKOTE - 562
114";
$leh_ladakh = "Engineer in-charge <br /> IAO-HANLE <br />Fort Road.SKARA <br
/>P.O.Box No.100<br />LEH-LADAKH - 194 101 <br /> (J & K)";
$kavalur = "Resident Scientist <br /> Vainu Bappu Observatory <br /> KAVALUR
- 635 701";

$_SESSION['voucher_value'] =  $_POST['voucher_to'];
if($_SESSION['voucher_value'] == k1)
{
$add_val =  $kodaikanal;
}
elseif($_SESSION['voucher_value'] == h1)
{
$add_val =  $hosakote;
}
elseif($_SESSION['voucher_value'] == l1)
{
$add_val =  $leh_ladakh;
}
elseif($_SESSION['voucher_value'] == k2)
{
$add_val =  $kavalur;
}

if ( !(isset ($_POST['delete']) ) ) {
$_SESSION['name_voucher']= $_POST['search_name'];
}
$search_temp = $_SESSION['name_voucher'];


if(isset($_POST['delete'])){
//$checkboxID= $_POST['checkbox'];
$array= $_POST['checkbox'];
foreach ($array as $key=>$value) {
$sql1 = "DELETE FROM $tbl_name WHERE voucher_number='$array[$key]'";
$result1 = mysql_query($sql1);
}


}
$sql="SELECT * FROM $tbl_name where name='$search_temp' &&
address='$add_val'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

if ($count == 0)
{
include('header.php');
print "<br />";
print "<br />";
print "Search does not find any such records";
print "<br />";
exit();
include('footer.php');
}
include('ser_mis.php');
}




else
{

$tbl_name = "voucherb";
if ( !(isset ($_POST['delete']) ) ) {
$_SESSION['name_voucher']= $_POST['search_name'];
}
$search_temp = $_SESSION['name_voucher'];


if(isset($_POST['delete'])){
//$checkboxID= $_POST['checkbox'];
$array= $_POST['checkbox'];
foreach ($array as $key=>$value) {
$sql1 = "DELETE FROM $tbl_name WHERE voucher_number='$array[$key]'";
$result1 = mysql_query($sql1);
}
if(!(mysql_affected_rows() == 1))
{
include('header.php');
print "<br />";
print "<br />";
print "Records has not been deleted. Please contact administrator";
include('footer.php');
exit();
}else
{
include('header.php');
print "<br />";
print "<br />";
print "The record(s) has been successfully deleted from database";
print "<br />";
exit();
include('footer.php');
}
}
$sql="SELECT * FROM $tbl_name where name='$search_temp'";// &&
address='$add_val'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

/*if ($count == 0)
{
include('header.php');
print "<br />";
print "<br />";
print "Search does not find any such records";
print "<br />";
exit();
include('footer.php');
}*/
include('ser_misb.php');
}

?>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux