| 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/public_html/websites/samaj/samaj/admin/ |
| Current File : /home/udaipurk/public_html/websites/samaj/samaj/admin/upload_1.php |
<?php
$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", "dashahu_samaj");
// set database user
define("DB_PASS", "RHfm5QkLQTx1");
// set database password
define("DB_NAME", "dashahu_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());
}
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet
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"]);
$date = trim($allDataInSheet[$i]["L"]);
$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,r_date) values('".$un_id."', '".$gotra."', '".$name."', '".$relation."', '".$age."', '".$education."', '".$p_address."', '".$c_address."', '".$mobile."', '".$relation_with."', '".$date."')");
$msg = '<div style="Padding:0 0 0 0;font-size:16px;color:#000">Record has been added.<br> <a href="index1.php">Go Back to Upload Page</a></div>';
} else {
$msg = '<div style="Padding:0 0 0 0;font-size:16px;color:#000">Record already exist.<br> <a href="index1.php">Go Back to Upload Page</a></div>';
}
}
?>
<div class="alert">
<?php echo $msg; ?>
</div>
<?php
include('footer.php');
?>