| Linux server27.hostingraja.org 2.6.32-954.3.5.lve1.4.93.el6.x86_64 #1 SMP Wed Oct 4 17:04:29 UTC 2023 x86_64 Path : /home/udaipurk/www/websites/samaj/samaj/member/ |
| Current File : /home/udaipurk/www/websites/samaj/samaj/member/upload.php |
<?php session_start();
$uploadedStatus = 0;
if ( isset($_POST["submit"]) ) {
if ( isset($_FILES["file"])) {
//if there was an error uploading the file
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else {
if (file_exists($_FILES["file"]["name"])) {
unlink($_FILES["file"]["name"]);
}
$file=$_FILES['file']['name'];
$storagename = "upload/".$file;
move_uploaded_file($_FILES["file"]["tmp_name"], $storagename);
$uploadedStatus = 1;
}
} else {
echo "No file selected <br />";
}
}
include('header.php');
/************************ YOUR DATABASE CONNECTION START HERE ****************************/
define ("DB_HOST", "localhost"); // set database host
define ("DB_USER", "root"); // set database user
define ("DB_PASS",""); // set database password
define ("DB_NAME","jain_samaj"); // set database name
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysqli_select_db(DB_NAME, $link) or die("Couldn't select database");
$databasetable = "member";
/************************ YOUR DATABASE CONNECTION END HERE ****************************/
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
include 'PHPExcel/IOFactory.php';
// This is the file path to be uploaded.
$inputFileName = "$storagename";
try {
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
} catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
$mid=$_SESSION['samaj_adyaksh'];
$qs=mysqli_query($link,"select r_location from reg_member where m_id='$mid'");
$qsr=mysqli_fetch_array($qs);
$location=$qsr['r_location'];
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet
$counter=0;
global $not_ins;
for($i=1;$i<=$arrayCount;$i++){
$un_id = trim($allDataInSheet[$i]["B"]);
$gotra = trim($allDataInSheet[$i]["C"]);
$name = trim($allDataInSheet[$i]["D"]);
$relation = trim($allDataInSheet[$i]["E"]);
$age = trim($allDataInSheet[$i]["F"]);
$education = trim($allDataInSheet[$i]["G"]);
$p_address = trim($allDataInSheet[$i]["H"]);
$c_address = trim($allDataInSheet[$i]["I"]);
$mobile = trim($allDataInSheet[$i]["J"]);
$relation_with = trim($allDataInSheet[$i]["K"]);
if($c_address==$location)
{
$query = "SELECT name FROM member WHERE un_id='".$un_id."' and surname = '".$gotra."' and name = '".$name."' and relation = '".$relation."' and age = '".$age."' and education = '".$education."' and p_address = '".$p_address."' and c_address = '".$c_address."' and mobile = '".$mobile."' and relation_with = '".$relation_with."'";
$sql = mysqli_query($link,$query);
$recResult = mysqli_fetch_array($sql);
$existName = $recResult["name"];
if($existName=="") {
$insertTable= mysqli_query($link,"insert into member (un_id,surname,name,relation,age,education,p_address,c_address,mobile,relation_with) values('".$un_id."', '".$gotra."', '".$name."', '".$relation."', '".$age."', '".$education."', '".$p_address."', '".$c_address."', '".$mobile."', '".$relation_with."')");
$msg1 = '<div style="Padding:0 0 0 0;font-size:16px;color:#000">Record has been added.<br></div>';
} else {
$msg1 = '<div style="Padding:0 0 0 0;font-size:16px;color:#000">Record already exist.<br> </div>';
}
}
else
{
$not_ins[$counter]=$name;
$city[$counter]=$c_address;
$counter=$counter+1;
}
}
if($counter>0)
{
echo '<div style="Padding:0 0 0 0;font-size:20px;color:#000">Sorry!!! You do not have sufficient privilege to insert the following data. </div><br>';
for($i=0;$i<$counter;$i++)
{ ?>
<div class="alert">
<?php echo '<div style="Padding:0 0 0 0;font-size:14px;color:#000">Name : '.$not_ins[$i].' <br> Current Location : '.$city[$i].'</div>'; ?>
</div>
<?php } }
?>
<div class="alert">
<?php echo $msg1; ?>
</div>
<?php
include('footer.php');
?>