Неопределенная переменная 'img'
<!DOCTYPE html> <meta charset="utf-8"> <title>New Entry: Letter <!-- For Date picker--> <!-- ************************************************************** --> <!----> $(document).ready(function() { $(document).ready(function() { $( "#datepicker" ).datepicker(); }); $(document).ready(function() { $( "#datepicker2" ).datepicker(); }); $(document).ready(function() { $( "#datepicker3" ).datepicker(); }); document.frmNewEntry.ltr_no.focus(); }); function submit_myform(form){ form.submit(); } /* function Foc() { document.frmNewEntry.ltr_no.focus(); } */ <div id="container-fluid"> <?php include('user_header.php'); ?> <?php include('../config/connection.php'); ?> <?php include("../library/functions.php"); ?> <?php include("../library/validations.php"); ?> <?php if($_SESSION['branch_code']<>100 ) { header("Location:../login.php"); }?> <p><br></p> <p><br></p> <p><br></p> <div id="body"> <?php $ltr_no=""; $ltr_docket_no=""; $ltr_docket_date=NULL; $ltr_year=0; $ltr_subject=""; $ltr_date=""; $ltr_category=""; $ltr_receivedate=""; $ltr_refno=""; $ltr_refdate=""; $ltr_priority=""; $from_name=""; $from_designation=""; $from_office_code=""; $ltr_entrydate=""; $present_status=""; $status_update_date=""; $ltr_pdf=""; $username=""; $remarks=""; $case_type_code=""; $court_case_no=""; if(isset($_POST['edit'])){ $_SESSION['ltr_docket_no1']= $_POST['ltr_docket_no1']; $_SESSION['ltr_year1']=$_POST['ltr_year1']; $sql="select * from master_letter where ltr_docket_no='$_SESSION[ltr_docket_no1]' and ltr_docket_year='$_SESSION[ltr_year1]'"; $rs=mysql_query($sql); if($row=mysql_fetch_array($rs)){ extract($row); } } if($ltr_docket_date!=NULL){ $ltr_docket_date=date("d-m-Y",strtotime($ltr_docket_date)); } if($ltr_date!=NULL){ $ltr_date=date("d-m-Y",strtotime($ltr_date)); } if($ltr_refdate!=NULL){ $ltr_refdate=date("d-m-Y",strtotime($ltr_refdate)); } //-------letter category/letter type combo $sql="SELECT type_code,type_name from master_lettertype"; $rs =mysql_query($sql); $ltr_cat_cmb="Select Category"; while($row=mysql_fetch_row($rs)) { if( (isset($_POST['ltr_category']) && $row[0]==$_POST['ltr_category']) || $row[0]==$ltr_category) $ltr_cat_cmb=$ltr_cat_cmb."<option value=$row[0] selected>".$row[1].""; else $ltr_cat_cmb=$ltr_cat_cmb."<option value=$row[0]>".$row[1].""; } //-------letter priority combo $sql="SELECT p_code,p_type from master_priority order by p_code desc"; $rs =mysql_query($sql); $ltr_prio_cmb="Select Priority"; while($row=mysql_fetch_row($rs)) { if( (isset($_POST['ltr_priority']) && $row[0]==$_POST['ltr_priority']) || $row[0]==$ltr_priority) $ltr_prio_cmb=$ltr_prio_cmb."<option value=$row[0] selected>".$row[1].""; else $ltr_prio_cmb=$ltr_prio_cmb."<option value=$row[0]>".$row[1].""; } //-------designation combo $sql="SELECT desig_code,designation from master_designation"; $rs =mysql_query($sql); $desig_cmb="Select Designation"; while($row=mysql_fetch_row($rs)) { if( (isset($_POST['from_designation']) && $row[0]==$_POST['from_designation']) || $row[0]==$from_designation) $desig_cmb=$desig_cmb."<option value=$row[0] selected>".$row[1].""; else $desig_cmb=$desig_cmb."<option value=$row[0]>".$row[1].""; } //-------office combo $sql="SELECT office_code,office_name,office_address from master_office"; $rs =mysql_query($sql); $office_cmb="Select Office"; while($row=mysql_fetch_row($rs)) { if( (isset($_POST['from_office_code']) && $row[0]==$_POST['from_office_code']) || $row[0]==$from_office_code) $office_cmb=$office_cmb."<option value=$row[0] selected>".$row[1].", $row[2]"; else $office_cmb=$office_cmb."<option value=$row[0]>".$row[1].", $row[2]"; } //Auto Docket No $max_ltr_docket_no=1; $sql="select max(ltr_docket_no) as max_ltr_docket_no from master_letter where ltr_docket_year=YEAR(curdate())"; $rs =mysql_query($sql); while($row=mysql_fetch_row($rs)) { if ($row[0] != NULL){ $max_ltr_docket_no = $row[0] + 1; } } // if($ltr_refdate=='0000-00-00') $ltr_refdate=''; // //-------Case Type combo $casetype_cmb="Select Case Type"; //if( (isset($_POST['ltr_category']) && ($_POST['ltr_category']==6 || $_POST['ltr_category']==7 || $_POST['ltr_category']==8)) || isset($_POST['edit'])) if(isset($_POST['ltr_category']) && $_POST['ltr_category']==6 || isset($_POST['edit'])) { $sql="SELECT * from master_court_case_type"; $rs =mysql_query($sql); while($row=mysql_fetch_row($rs)) { if( (isset($_POST['case_type_code']) && $row[0]==$_POST['case_type_code']) || $row[0]==$case_type_code) $casetype_cmb=$casetype_cmb."<option value=$row[0] selected>".$row[1].""; else $casetype_cmb=$casetype_cmb."<option value=$row[0]>".$row[1].""; } } ?> <div class="row"> <div class="col-md-2"></div> <div class="col-md-8"> <div class="panel panel-primary"> <div class="panel-heading">New Entry: Letter</div> <div class="panel-body"> <div class="row"> <div class="form-group"> Docket No. <div class="col-md-5"> </div> </div> </div> <div class="row"> <div class="form-group"> Docket Date <div class="col-md-5"> " style="width:200px" tabindex=2> </div> </div> </div> <hr> <div class="row"> <div class="col-md-6"> <div class="form-group"> Letter No. <span class="help-block"> Letter no is required..</span> </div> </div> <div class="col-md-6"> Reference No. </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> Letter Date. <span class="help-block"> Pick up a date..</span> </div> </div> <div class="col-md-6"> Reference Date. </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> Subject. <?php echo isset($_POST['ltr_subject'])?$_POST['ltr_subject']:$ltr_subject; ?> <span class="help-block">Please add subject</span> </div> </div> <div class="col-md-6"> Letter From. </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> Category. <?php echo $ltr_cat_cmb;?> <span class="help-block">Please select category..</span> </div> </div> <div class="col-md-6"> <div class="form-group"> Designation. <?php echo $desig_cmb;?> <span class="help-block">Please select a designation..</span> </div> </div> </div> <div class="row"> <div class="col-md-6"> Case Type / No:. <div class="row"> <div class="col-md-5"> <?php echo $casetype_cmb;?> </div> <div class="col-md-1">/</div> <div class="col-md-6"> </div> </div> </div> <div class="col-md-6"> <div class="form-group"> Office Name. <?php echo $office_cmb;?> <span class="help-block">Please select a office name..</span> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> Priority. <?php echo $ltr_prio_cmb;?> <span class="help-block">Please select priority....</span> </div> </div> <div class="col-md-6"> Remarks. <?php echo isset($_POST['remarks'])?$_POST['remarks']:$remarks; ?> </div> </div><br> <div class="row"> <div class="col-md-2"></div> <div class="col-md-6"> <font color="red">(Only PDF and Max Size: 5 MB)</font> </div> <div class="col-md-2"> </div> <div class="col-md-2"></div> </div> <p><br></p> <div class="row"> <div class="col-md-4"></div> <div class="col-md-4"> </div> <div class="col-md-4"></div> </div> </div> <div class="panel-footer">fffdd</div> </div> </div> </div> <?php if(isset($_POST['new'])) { $ltr_docket_no =mysql_real_escape_string($_POST['ltr_docket_no']); $ltr_docket_date =date("Y-m-d", strtotime(mysql_real_escape_string($_POST['ltr_docket_date']))); $ltr_no =mysql_real_escape_string($_POST['ltr_no']); $ltr_year =date('Y', strtotime(mysql_real_escape_string($_POST['ltr_docket_date']))); $ltr_subject =mysql_real_escape_string($_POST['ltr_subject']); $ltr_date =date("Y-m-d", strtotime(mysql_real_escape_string($_POST['ltr_date']))); $ltr_category =mysql_real_escape_string($_POST['ltr_category']); $ltr_refno =mysql_real_escape_string($_POST['ltr_refno']); $ltr_refdate =date("Y-m-d", strtotime(mysql_real_escape_string($_POST['ltr_refdate']))); if($ltr_refdate=="1970-01-01") $ltr_refdate ="0000-00-00"; $ltr_priority =mysql_real_escape_string($_POST['ltr_priority']); $from_name =mysql_real_escape_string($_POST['from_name']); $from_designation =mysql_real_escape_string($_POST['from_designation']); $from_office_code =mysql_real_escape_string($_POST['from_office_code']); $ltr_entrydate =date("Y-m-d"); $present_status ="1"; $ltr_pdf =""; $remarks =mysql_real_escape_string($_POST['remarks']); $case_type_code =mysql_real_escape_string($_POST['case_type_code']); if ($case_type_code==NULL) { $case_type_code =0; } $court_case_no =mysql_real_escape_string($_POST['court_case_no']); //VALIDATION if ($ltr_docket_no==NULL) { msg("please enter docket number","red"); set_focus('ltr_docket_no'); } else if ($ltr_docket_date==NULL || $ltr_docket_date=='1970-01-01') { msg("please enter docket date","red"); set_focus('datepicker'); } else if($ltr_no==NULL) { msg("please enter letter number","red"); set_focus('ltr_no'); } else if($ltr_date==NULL || $ltr_date=='1970-01-01') { msg("please enter letter date","red"); set_focus('datepicker2'); } else if($ltr_subject==NULL) { msg("please enter letter subject","red"); set_focus('ltr_subject'); } else if($ltr_category==NULL) { msg("please select letter category","red"); set_focus('ltr_category'); } else if($ltr_priority==NULL) { msg("please select letter priority","red"); set_focus('ltr_priority'); } else if($from_designation==NULL) { msg("please select designation","red"); set_focus('from_designation'); } else if($from_office_code==NULL) { msg("please select office name","red"); set_focus('from_office_code'); } else{ {$image=addslashes(file_get_contents($_FILES['img']['tmp_name'])); $image=base64_encode($image); }mysql_query("insert into image1 values('$image')"); $sql="INSERT INTO master_letter(ltr_docket_no,ltr_docket_date, ltr_docket_year, ltr_no, ltr_subject, ltr_date, ltr_category, ltr_refno, ltr_refdate, ltr_priority, from_name, from_designation, from_office_code, ltr_entrydate, present_status, forwardedYN, ltr_pdf, remarks, case_type_code, court_case_no) VALUES('$ltr_docket_no','$ltr_docket_date','$ltr_year', '$ltr_no', '$ltr_subject', '$ltr_date', '$ltr_category', '$ltr_refno', '$ltr_refdate', '$ltr_priority', '$from_name', '$from_designation', '$from_office_code', '$ltr_entrydate', '$present_status', 'N', '$ltr_pdf', '$remarks', '$case_type_code', '$court_case_no')"; if(mysql_query($sql)){ } else{ echo "<center><font color="red">".mysql_error()."</font></center>"; } } } if(isset($_POST['update'])) { $ltr_docket_no =mysql_real_escape_string($_POST['ltr_docket_no']); $ltr_docket_date =date("Y-m-d", strtotime(mysql_real_escape_string($_POST['ltr_docket_date']))); $ltr_no =mysql_real_escape_string($_POST['ltr_no']); $ltr_year =date('Y', strtotime(mysql_real_escape_string($_POST['ltr_docket_date']))); $ltr_subject =mysql_real_escape_string($_POST['ltr_subject']); $ltr_date =date("Y-m-d", strtotime(mysql_real_escape_string($_POST['ltr_date']))); $ltr_category =mysql_real_escape_string($_POST['ltr_category']); $ltr_refno =mysql_real_escape_string($_POST['ltr_refno']); $ltr_refdate =date("Y-m-d", strtotime(mysql_real_escape_string($_POST['ltr_refdate']))); if($ltr_refdate=="1970-01-01") $ltr_refdate ="0000-00-00"; $ltr_priority =mysql_real_escape_string($_POST['ltr_priority']); $from_name =mysql_real_escape_string($_POST['from_name']); $from_designation =mysql_real_escape_string($_POST['from_designation']); $from_office_code =mysql_real_escape_string($_POST['from_office_code']); $ltr_entrydate =date("Y-m-d"); $present_status ="1"; $ltr_pdf =""; $remarks =mysql_real_escape_string($_POST['remarks']); $case_type_code =mysql_real_escape_string($_POST['case_type_code']); if ($case_type_code==NULL) { $case_type_code =0; } $court_case_no =mysql_real_escape_string($_POST['court_case_no']); //****** readonly('ltr_docket_no'); readonly('datepicker'); disable('new'); //****** //VALIDATION if ($ltr_docket_no==NULL) { msg("please enter docket number","red"); set_focus('ltr_docket_no'); } else if ($ltr_docket_date==NULL || $ltr_docket_date=='1970-01-01') { msg("please enter docket date","red"); set_focus('datepicker'); } else if($ltr_no==NULL) { msg("please enter letter number","red"); set_focus('ltr_no'); } else if($ltr_date==NULL || $ltr_date=='1970-01-01') { msg("please enter letter date","red"); set_focus('datepicker2'); } else if($ltr_subject==NULL) { msg("please enter letter subject","red"); set_focus('ltr_subject'); } else if($ltr_category==NULL) { msg("please select letter category","red"); set_focus('ltr_category'); } else if($ltr_priority==NULL) { msg("please select letter priority","red"); set_focus('ltr_priority'); } else if($from_designation==NULL) { msg("please select designation","red"); set_focus('from_designation'); } else if($from_office_code==NULL) { msg("please select office name","red"); set_focus('from_office_code'); } else{ $sql="UPDATE master_letter SET ltr_docket_date='$ltr_docket_date',ltr_no='$ltr_no' , ltr_subject= '$ltr_subject', ltr_date='$ltr_date', ltr_category= '$ltr_category', ltr_refno='$ltr_refno', ltr_refdate='$ltr_refdate', ltr_priority='$ltr_priority', from_name='$from_name', from_designation='$from_designation', from_office_code='$from_office_code', remarks='$remarks', case_type_code='$case_type_code', court_case_no='$court_case_no' WHERE ltr_docket_no='$_SESSION[ltr_docket_no1]' AND ltr_docket_year='$_SESSION[ltr_year1]'"; if(mysql_query($sql)){ //msg_js("Record Saved successfully"); $_SESSION['pdf_path']=NULL; $_SESSION['pdf_path']="pdf/".date("Y",strtotime($ltr_docket_date))."/".date("m",strtotime($ltr_docket_date)); $_SESSION['ltr_docket_no']=$ltr_docket_no; $_SESSION['ltr_docket_year']=$ltr_year; url_loc("letter_update_success.php"); } else{ echo "<center><font color="red">".mysql_error()."</font></center>"; } } } if(isset($_POST['del'])){ $_SESSION['ltr_docket_no1']= $_POST['ltr_docket_no1']; $_SESSION['ltr_year1']=$_POST['ltr_year1']; $sql="delete from master_letter where ltr_docket_no='$_SESSION[ltr_docket_no1]' && ltr_docket_year='$_SESSION[ltr_year1]'"; if($_POST['ltr_pdf']!="") unlink("../".$_POST['ltr_pdf']) or die("Sorry Unable to delete pdf"); if(mysql_query($sql)){ msg_js("Record Deleted Successfully"); url_loc("letter_entry.php"); } else{ msg_js("Sorry! Unable to delete record"); } $_SESSION['ltr_docket_no1']= NULL; $_SESSION['ltr_year1']=NULL; } if(isset($_POST['edit'])){ readonly('ltr_docket_no'); readonly('datepicker'); disable('new'); } //********* anzum (upload pdf later time)****** if(isset($_POST['upload1'])){ $_SESSION['ltr_docket_no']= $_POST['ltr_docket_no11']; $_SESSION['ltr_docket_year']=$_POST['ltr_docket_year11']; $ltr_docket_date=$_POST['ltr_docket_date11']; $_SESSION['pdf_path']="pdf/".date("Y",strtotime($ltr_docket_date))."/".date("m",strtotime($ltr_docket_date)); url_loc("upload_after_entry.php"); //$_SESSION['ltr_year1']=$_POST['ltr_year1']; //$_SESSION['ltr_docket_no']=$ltr_docket_no; } //*******anzum ?> </div> </div><?php include('../footer.php'); ?>
Что я уже пробовал:
undefined index 'img'
эта переменная используется для получения изображения от пользователя и сохранения его в базе данных.
я определил переменную в форме и вызвал ее
"if(isset($_POST['new']))" .. . $image=addslashes(file_get_contents($_FILES['img']['tmp_name'])); // here it is showing error. that is the undefined variale img